It contains all the properties we need to instantiate a Device: id, name,
type, cert, capabilities and protocol version. Before, we had a mix of
passing those around as arguments or passing identity packets (ie: json).
This simplifies the Device class quite a bit.
Now, the BaseLink subclasses need to implement getDeviceInfo() interface
that returns a DeviceInfo, which is what we will pass around and eventually
use to instantiate a Device.
This means that identity packets are an implementation detail of the
LanLinkProvider and that other implementations could get the DeviceInfo
in a different way.
Bubble up exceptions instead of using giant, generic try-catch blocks.
The UDP and TCP listener loops are now where we catch all the exceptions that might happen handling the incoming packets.
Also, the creation of worker threads now happens in the listener loops as well instead of the inner functions.
Finally the `broadcastUdpPacket` function has been split in `broadcastUdpIdentityPacket` and `sendUdpIdentityPacket` (the first calls the second).
Since we now require API 21, we can use setAudioAttributes instead of
the deprecated setAudioStreamType.
Since we already require WAKE_LOCK for the SMS plugin, we can use it
here to prevent the screen from sleeping.
The version of the library we used stopped working in 2020 when the names
database it tries to download got deleted from the master branch of their
Github repo. There's a newer version, but it seems to have lost the
fetch-from-the-internet functionality (it only bundles a list of names) and
for some reason it crashes when I tested it (I've opened an issue on their
repo). Since Google now provides a CSV with all the Android device names
that exist, I've replaced the library by my own function that downloads the
CSV file (~3MB) in the first run of the app and looks for the name there.
By passing a port the implementation of DatagramSocket already binds to
it, making it fail if the port was already in use even if we did
setReuseAddress because that happened after binding.