Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 95b0c191 authored by Alexander Wuerstlein's avatar Alexander Wuerstlein Committed by Steve Kondik
Browse files

connectivity-service: fix/improve unique hostname

ConnectivityService should set the net.hostname property to either
the current DEVICE_HOSTNAME or android-ANDROID_ID or leave net.hostname
unchanged if already set. However, the logic was flawed such that if
DEVICE_HOSTNAME was empty but net.hostname was not, net.hostname would
always be set to an empty string, leading to DHCP breakage later on.

The logic has been fixed, clarified and improved such that:
net.hostname will only be changed if it is empty. If net.hostname is
empty, it will be set to either (in order): the nonempty value of
DEVICE_HOSTNAME, android-ANDROID_ID or android-r-RANDOM_NUMBER. The last
option is an addition to have a sensible fallback in case both
DEVICE_HOSTNAME and ANDROID_ID are empty.

The random number is generated by java.util.Random, because I consider
cryptographically strong randomness unnecessary here and think possible
blocking in SecureRandom might be undesirable.

Thanks to stargo for pointing me to the right place to edit.
Thanks to Ethan Chen for his stylistic advice.

Change-Id: I603ab4d6a265456bf4fa310939965cfa677fc881
parent d88569d1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment