This commit is contained in:
Aleksander Nowakowski 2017-11-30 15:38:17 +01:00
parent 1f5b13e89c
commit 8b3b09f536
4 changed files with 22 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -132,6 +132,7 @@ public abstract class DfuBaseService extends IntentService implements DfuProgres
* <p>
* Search for occurrences of EXTRA_RESTORE_BOND in this file to check the implementation and get more details.
* </p>
* <p>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.</p>
*/
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)}).</p>
*
* <p>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.</p>
* <p>The default value of this flag is <code>false</code></p>
* <p>The default value of this flag is <code>false</code>.</p>
*
* <p>This flag is ignored when Secure DFU Buttonless Service is used. It will keep or remove the bond depending on the Buttonless service type.</p>
*/
public static final String EXTRA_KEEP_BOND = "no.nordicsemi.android.dfu.extra.EXTRA_KEEP_BOND";
/**

View File

@ -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.
*
* <p>This flag is ignored when Secure DFU Buttonless Service is used. It will keep or remove the
* bond depending on the Buttonless service type.</p>
* @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.
*
* <p>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.</p>
* @param restoreBond whether the bond should be created after the DFU is complete.
* @return the builder
*/