Pairing some devices requires a PIN to be entered. E.g. the flow is: confirm you'd like to pair, pass off to Android which prompts for a PIN to pair with (typically shows up on the non-phone device's screen or is hard coded in the manual), then return back to the app.
When this pairing request screen pops up, it takes focus. This invokes onPause and onStop in the DiscoveryActivity, which removes the BlueTooth broadcast receivers. Returning focus (after successful pairing), there's nothing to listen to the event. Practically speaking, GadgetBridge last saw the device as BOND_BONDING, so it's out of sync. If queried, the device is BOND_BONDED, so it's good to move on to the next step.
Many existing pairing activities (Lenovo, MiBand, Pebble, Watch9) have an implementation of onResume() to presumably tackle this issue, this adds it to `DiscoveryActivity` as well. Testing with some other supporting code, this allows a Garmin vivosport to appear in Gadgetbridge.
THIS STILL REQUIRES MI FIT AND YOUR EXTRACTED KEY
HOWTO:
1) press + button in Gadgerbridge
2) LONG PRESS Mi Band 4
3) Tap "Auth Key"
4) Enter your key prefixed with 0x (eg. 0x112233445566778899aabbccddeeff00)
5) Go back
6) Tap Mi Band 4
Success? You tell me.
This allows to construct per-device settings by device type very easily
device coordinators just do the following to declare which setting they support,
the settings activity is then composed at runtime.
@Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_miband3,
R.xml.devicesettings_swipeunlock,
R.xml.devicesettings_pairingkey
};
}
When connecting to a new device, a random key gets generated, which can be
looked up from the device specific settings (accessible via the gear icon in
the device card in the main activity). Old devices keep their 0123456789@ABCDE
key, they have to be re-paired to change that.
During pairing, long-pressing the device candidate in the discovery activity
will also start the device specific settings activity, where the auth key
can be set manually priror to pairing. This is usefull to keep the ability to
pair one device with multiple android devices.
Fixes#1308
So we do need to set the language both on change and onCreate()
For some reason, the title bar of the SettingsActivity is not updated on recreate().
Closes#787
- cleaned up the DeviceService.connect() variants
- discovery: pass the device candidate around instead of the mac address
Attempts to fix#512, #514, #518