From 8b3b09f536964c5217912b428aab7035ab4e37fb Mon Sep 17 00:00:00 2001
From: Aleksander Nowakowski
Date: Thu, 30 Nov 2017 15:38:17 +0100
Subject: [PATCH] #89 fixed
---
.../dfu/ButtonlessDfuWithBondSharingImpl.java | 4 ++++
.../dfu/ButtonlessDfuWithoutBondSharingImpl.java | 4 ++++
.../no/nordicsemi/android/dfu/DfuBaseService.java | 5 ++++-
.../nordicsemi/android/dfu/DfuServiceInitiator.java | 12 ++++++++++--
4 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/ButtonlessDfuWithBondSharingImpl.java b/dfu/src/main/java/no/nordicsemi/android/dfu/ButtonlessDfuWithBondSharingImpl.java
index dd7a4d4..f47d4d4 100644
--- a/dfu/src/main/java/no/nordicsemi/android/dfu/ButtonlessDfuWithBondSharingImpl.java
+++ b/dfu/src/main/java/no/nordicsemi/android/dfu/ButtonlessDfuWithBondSharingImpl.java
@@ -66,6 +66,10 @@ import no.nordicsemi.android.dfu.internal.exception.UploadAbortedException;
mService.terminateConnection(mGatt, DfuBaseService.ERROR_DEVICE_NOT_BONDED);
return;
}
+ // In Secure DFU with Bond Sharing the bond information should not be removed
+ intent.putExtra(DfuBaseService.EXTRA_KEEP_BOND, true);
+ intent.putExtra(DfuBaseService.EXTRA_RESTORE_BOND, false);
+
super.performDfu(intent);
}
}
diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/ButtonlessDfuWithoutBondSharingImpl.java b/dfu/src/main/java/no/nordicsemi/android/dfu/ButtonlessDfuWithoutBondSharingImpl.java
index dd70dc4..909f8e2 100644
--- a/dfu/src/main/java/no/nordicsemi/android/dfu/ButtonlessDfuWithoutBondSharingImpl.java
+++ b/dfu/src/main/java/no/nordicsemi/android/dfu/ButtonlessDfuWithoutBondSharingImpl.java
@@ -69,6 +69,10 @@ import no.nordicsemi.android.dfu.internal.exception.UploadAbortedException;
@Override
public void performDfu(final Intent intent) throws DfuException, DeviceDisconnectedException, UploadAbortedException {
logi("Buttonless service without bond sharing found -> SDK 13 or newer");
+ if (isBonded()) {
+ logw("Device is paired! Use Buttonless DFU with Bond Sharing instead (SDK 14 or newer)");
+ }
+
super.performDfu(intent);
}
}
diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java b/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java
index d16fccd..aa01b06 100644
--- a/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java
+++ b/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java
@@ -132,6 +132,7 @@ public abstract class DfuBaseService extends IntentService implements DfuProgres
*
* Search for occurrences of EXTRA_RESTORE_BOND in this file to check the implementation and get more details.
*
+ * This flag is ignored when Secure DFU Buttonless Service is used. It will keep or will not restore the bond depending on the Buttonless service type.
*/
public static final String EXTRA_RESTORE_BOND = "no.nordicsemi.android.dfu.extra.EXTRA_RESTORE_BOND";
/**
@@ -146,7 +147,9 @@ public abstract class DfuBaseService extends IntentService implements DfuProgres
* service will remove the bond information from the phone and force to refresh the device cache (see {@link #refreshDeviceCache(android.bluetooth.BluetoothGatt, boolean)}).
*
* In contrast to {@link #EXTRA_RESTORE_BOND} this flag will not remove the old bonding and recreate a new one, but will keep the bond information untouched.
- * The default value of this flag is false
+ * The default value of this flag is false
.
+ *
+ * This flag is ignored when Secure DFU Buttonless Service is used. It will keep or remove the bond depending on the Buttonless service type.
*/
public static final String EXTRA_KEEP_BOND = "no.nordicsemi.android.dfu.extra.EXTRA_KEEP_BOND";
/**
diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/DfuServiceInitiator.java b/dfu/src/main/java/no/nordicsemi/android/dfu/DfuServiceInitiator.java
index 18872d1..694ea66 100644
--- a/dfu/src/main/java/no/nordicsemi/android/dfu/DfuServiceInitiator.java
+++ b/dfu/src/main/java/no/nordicsemi/android/dfu/DfuServiceInitiator.java
@@ -126,8 +126,13 @@ public class DfuServiceInitiator {
}
/**
- * Sets whether the bond information should be preserver after flashing new application. This feature requires DFU Bootloader version 0.6 or newer (SDK 8.0.0+).
- * Please see the {@link DfuBaseService#EXTRA_KEEP_BOND} for more information regarding requirements. Remember that currently updating the Soft Device will remove the bond information.
+ * Sets whether the bond information should be preserver after flashing new application.
+ * This feature requires DFU Bootloader version 0.6 or newer (SDK 8.0.0+).
+ * Please see the {@link DfuBaseService#EXTRA_KEEP_BOND} for more information regarding requirements.
+ * Remember that currently updating the Soft Device will remove the bond information.
+ *
+ * This flag is ignored when Secure DFU Buttonless Service is used. It will keep or remove the
+ * bond depending on the Buttonless service type.
* @param keepBond whether the bond information should be preserved in the new application.
* @return the builder
*/
@@ -139,6 +144,9 @@ public class DfuServiceInitiator {
/**
* Sets whether the bond should be created after the DFU is complete.
* Please see the {@link DfuBaseService#EXTRA_RESTORE_BOND} for more information regarding requirements.
+ *
+ * This flag is ignored when Secure DFU Buttonless Service is used. It will keep or will not
+ * restore the bond depending on the Buttonless service type.
* @param restoreBond whether the bond should be created after the DFU is complete.
* @return the builder
*/