diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3b6e831c5..9635721e9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
* Work around broken layout in database management activity
* Show toast in case no app is installed which can handle GPX files
* Mi Band 4/Amazfit Bip Lite: Trim white spaces and new lines from auth key
+* Mi Band 4/Amazfit Bip Lite: Display a toast and do not try to pair if there was no auth key supplied
#### Version 0.36.2
* Amazfit Bip: Untested support for Lite variant
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ConfigureAlarms.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ConfigureAlarms.java
index 1183a67ce..6293cb03c 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ConfigureAlarms.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ConfigureAlarms.java
@@ -80,6 +80,7 @@ public class ConfigureAlarms extends AbstractGBActivity {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQ_CONFIGURE_ALARM) {
avoidSendAlarmsToDevice = false;
updateAlarmsFromDB();
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java
index d29bacc70..f88c692cf 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java
@@ -35,6 +35,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
@@ -616,6 +617,17 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
stopDiscovery();
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(deviceCandidate);
LOG.info("Using device candidate " + deviceCandidate + " with coordinator: " + coordinator.getClass());
+
+ if (coordinator.getBondingStyle() == DeviceCoordinator.BONDING_STYLE_REQUIRE_KEY) {
+ SharedPreferences sharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(deviceCandidate.getMacAddress());
+
+ String authKey = sharedPrefs.getString("authkey", null);
+ if (authKey == null || authKey.isEmpty() || authKey.getBytes().length < 34 || !authKey.substring(0, 2).equals("0x")) {
+ GB.toast(DiscoveryActivity.this, getString(R.string.discovery_need_to_enter_authkey), Toast.LENGTH_LONG, GB.WARN);
+ return;
+ }
+ }
+
Class extends Activity> pairingActivity = coordinator.getPairingActivity();
if (pairingActivity != null) {
Intent intent = new Intent(this, pairingActivity);
@@ -623,7 +635,7 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
startActivity(intent);
} else {
GBDevice device = DeviceHelper.getInstance().toSupportedDevice(deviceCandidate);
- int bondingStyle = coordinator.getBondingStyle(device);
+ int bondingStyle = coordinator.getBondingStyle();
if (bondingStyle == DeviceCoordinator.BONDING_STYLE_NONE) {
LOG.info("No bonding needed, according to coordinator, so connecting right away");
connectAndFinish(device);
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java
index 6d8a030f3..46bd46344 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java
@@ -136,7 +136,7 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
}
@Override
- public int getBondingStyle(GBDevice device) {
+ public int getBondingStyle() {
return BONDING_STYLE_ASK;
}
@@ -159,6 +159,7 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
return false;
}
+ @NonNull
@Override
public int[] getColorPresets() {
return new int[0];
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java
index a9d7fd7e7..567fa5b8d 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java
@@ -29,7 +29,6 @@ import java.util.Collection;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import nodomain.freeyourgadget.gadgetbridge.GBException;
-import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsFragment;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
@@ -63,6 +62,11 @@ public interface DeviceCoordinator {
*/
int BONDING_STYLE_ASK = 2;
+ /**
+ * A secret key has to be entered before connecting
+ */
+ int BONDING_STYLE_REQUIRE_KEY = 3;
+
/**
* Checks whether this coordinator handles the given candidate.
* Returns the supported device type for the given candidate or
@@ -224,9 +228,8 @@ public interface DeviceCoordinator {
/**
* Returns how/if the given device should be bonded before connecting to it.
- * @param device
*/
- int getBondingStyle(GBDevice device);
+ int getBondingStyle();
/**
* Indicates whether the device has some kind of calender we can sync to.
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/UnknownDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/UnknownDeviceCoordinator.java
index df6fc0596..255cacdd7 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/UnknownDeviceCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/UnknownDeviceCoordinator.java
@@ -93,6 +93,7 @@ public class UnknownDeviceCoordinator extends AbstractDeviceCoordinator {
sampleProvider = new UnknownSampleProvider();
}
+ @NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
return DeviceType.UNKNOWN;
@@ -197,6 +198,7 @@ public class UnknownDeviceCoordinator extends AbstractDeviceCoordinator {
return false;
}
+ @NonNull
@Override
public int[] getColorPresets() {
return new int[0];
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casiogb6900/CasioGB6900DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casiogb6900/CasioGB6900DeviceCoordinator.java
index cb9dc6cad..3bd12815a 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casiogb6900/CasioGB6900DeviceCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casiogb6900/CasioGB6900DeviceCoordinator.java
@@ -58,7 +58,7 @@ public class CasioGB6900DeviceCoordinator extends AbstractDeviceCoordinator {
}
@Override
- public int getBondingStyle(GBDevice deviceCandidate){
+ public int getBondingStyle(){
return BONDING_STYLE_BOND;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java
index 621ae54d2..b9e3326d5 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java
@@ -84,7 +84,7 @@ public class HPlusCoordinator extends AbstractDeviceCoordinator {
}
@Override
- public int getBondingStyle(GBDevice deviceCandidate){
+ public int getBondingStyle(){
return BONDING_STYLE_NONE;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipLiteCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipLiteCoordinator.java
index d25067b77..b2ce87a0b 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipLiteCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipLiteCoordinator.java
@@ -57,4 +57,9 @@ public class AmazfitBipLiteCoordinator extends AmazfitBipCoordinator {
public InstallHandler findInstallHandler(Uri uri, Context context) {
return null;
}
+
+ @Override
+ public int getBondingStyle() {
+ return BONDING_STYLE_REQUIRE_KEY;
+ }
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java
index 68ce12840..c451e8d49 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java
@@ -97,4 +97,9 @@ public class MiBand4Coordinator extends HuamiCoordinator {
R.xml.devicesettings_pairingkey
};
}
+
+ @Override
+ public int getBondingStyle() {
+ return BONDING_STYLE_REQUIRE_KEY;
+ }
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/id115/ID115Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/id115/ID115Coordinator.java
index f60532eaf..fb8717b6d 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/id115/ID115Coordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/id115/ID115Coordinator.java
@@ -66,7 +66,7 @@ public class ID115Coordinator extends AbstractDeviceCoordinator {
}
@Override
- public int getBondingStyle(GBDevice deviceCandidate){
+ public int getBondingStyle(){
return BONDING_STYLE_NONE;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/jyou/BFH16DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/jyou/BFH16DeviceCoordinator.java
index 020a38485..dd90e41a4 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/jyou/BFH16DeviceCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/jyou/BFH16DeviceCoordinator.java
@@ -70,6 +70,7 @@ public class BFH16DeviceCoordinator extends AbstractDeviceCoordinator
return Collections.singletonList(filter);
}
+ @NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
@@ -85,7 +86,7 @@ public class BFH16DeviceCoordinator extends AbstractDeviceCoordinator
}
@Override
- public int getBondingStyle(GBDevice deviceCandidate){
+ public int getBondingStyle(){
return BONDING_STYLE_NONE;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/jyou/TeclastH30Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/jyou/TeclastH30Coordinator.java
index 4c994bf1f..68a464af4 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/jyou/TeclastH30Coordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/jyou/TeclastH30Coordinator.java
@@ -82,7 +82,7 @@ public class TeclastH30Coordinator extends AbstractDeviceCoordinator {
}
@Override
- public int getBondingStyle(GBDevice deviceCandidate){
+ public int getBondingStyle(){
return BONDING_STYLE_NONE;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/makibeshr3/MakibesHR3Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/makibeshr3/MakibesHR3Coordinator.java
index 2b6276b75..d17f535e1 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/makibeshr3/MakibesHR3Coordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/makibeshr3/MakibesHR3Coordinator.java
@@ -19,7 +19,6 @@ package nodomain.freeyourgadget.gadgetbridge.devices.makibeshr3;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
-import java.util.GregorianCalendar;
import android.app.Activity;
import android.content.Context;
@@ -162,7 +161,7 @@ public class MakibesHR3Coordinator extends AbstractDeviceCoordinator {
}
@Override
- public int getBondingStyle(GBDevice deviceCandidate) {
+ public int getBondingStyle() {
return BONDING_STYLE_NONE;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/mijia_lywsd02/MijiaLywsd02Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/mijia_lywsd02/MijiaLywsd02Coordinator.java
index d0bcdee58..76e05fdba 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/mijia_lywsd02/MijiaLywsd02Coordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/mijia_lywsd02/MijiaLywsd02Coordinator.java
@@ -49,7 +49,7 @@ public class MijiaLywsd02Coordinator extends AbstractDeviceCoordinator {
}
@Override
- public int getBondingStyle(GBDevice deviceCandidate) {
+ public int getBondingStyle() {
return BONDING_STYLE_NONE;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miscale2/MiScale2DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miscale2/MiScale2DeviceCoordinator.java
index c2308026f..c042e04d4 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miscale2/MiScale2DeviceCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miscale2/MiScale2DeviceCoordinator.java
@@ -85,7 +85,7 @@ public class MiScale2DeviceCoordinator extends AbstractDeviceCoordinator {
}
@Override
- public int getBondingStyle(GBDevice device) {
+ public int getBondingStyle() {
return super.BONDING_STYLE_NONE;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/no1f1/No1F1Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/no1f1/No1F1Coordinator.java
index 4affefa09..79c5943a3 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/no1f1/No1F1Coordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/no1f1/No1F1Coordinator.java
@@ -71,7 +71,7 @@ public class No1F1Coordinator extends AbstractDeviceCoordinator {
}
@Override
- public int getBondingStyle(GBDevice deviceCandidate) {
+ public int getBondingStyle() {
return BONDING_STYLE_NONE;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/roidmi/RoidmiCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/roidmi/RoidmiCoordinator.java
index 1aa75024d..574c2f4fe 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/roidmi/RoidmiCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/roidmi/RoidmiCoordinator.java
@@ -44,7 +44,7 @@ public abstract class RoidmiCoordinator extends AbstractDeviceCoordinator {
}
@Override
- public int getBondingStyle(GBDevice device) {
+ public int getBondingStyle() {
return BONDING_STYLE_BOND;
}
@@ -133,6 +133,7 @@ public abstract class RoidmiCoordinator extends AbstractDeviceCoordinator {
return true;
}
+ @NonNull
@Override
public int[] getColorPresets() {
return RoidmiConst.COLOR_PRESETS;
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/watch9/Watch9DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/watch9/Watch9DeviceCoordinator.java
index 878076f94..18b0a8844 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/watch9/Watch9DeviceCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/watch9/Watch9DeviceCoordinator.java
@@ -77,7 +77,7 @@ public class Watch9DeviceCoordinator extends AbstractDeviceCoordinator {
}
@Override
- public int getBondingStyle(GBDevice deviceCandidate) {
+ public int getBondingStyle() {
return BONDING_STYLE_NONE;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeCoordinator.java
index 3f80a8b53..3ddc4cdc3 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/zetime/ZeTimeCoordinator.java
@@ -153,7 +153,7 @@ public class ZeTimeCoordinator extends AbstractDeviceCoordinator {
}
@Override
- public int getBondingStyle(GBDevice device) {
+ public int getBondingStyle() {
return BONDING_STYLE_NONE;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/BluetoothPairingRequestReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/BluetoothPairingRequestReceiver.java
index c262b00fe..70d39648d 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/BluetoothPairingRequestReceiver.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/BluetoothPairingRequestReceiver.java
@@ -61,7 +61,7 @@ public class BluetoothPairingRequestReceiver extends BroadcastReceiver {
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
try {
- if (coordinator.getBondingStyle(gbDevice) == DeviceCoordinator.BONDING_STYLE_NONE) {
+ if (coordinator.getBondingStyle() == DeviceCoordinator.BONDING_STYLE_NONE) {
LOG.info("Aborting unwanted pairing request");
abortBroadcast();
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipLiteSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipLiteSupport.java
index 4db0af32b..fb6c6bb61 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipLiteSupport.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip/AmazfitBipLiteSupport.java
@@ -20,8 +20,6 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip;
import android.content.Context;
import android.net.Uri;
-import java.io.IOException;
-
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
public class AmazfitBipLiteSupport extends AmazfitBipSupport {
@@ -37,7 +35,7 @@ public class AmazfitBipLiteSupport extends AmazfitBipSupport {
}
@Override
- public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException {
+ public HuamiFWHelper createFWHelper(Uri uri, Context context) {
return null;
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index bde362b57..bbe2a38f4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -300,6 +300,7 @@
When your Mi Band vibrates and blinks, tap it a few times in a row.
Install
Make your device discoverable. Currently connected devices will likely not be discovered. Activate location (e.g. GPS) on Android 6+. Disable Privacy Guard for Gadgetbridge, because it may crash and reboot your phone. If no device is found after a few minutes, try again after rebooting your mobile device.
+ This device needs a secret auth key, long press on the device to enter it. Read the wiki.
Note:
Device image
Name/Alias