From 07d661f7cb46a02116a6df95acfc79f1b5185498 Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Thu, 20 Nov 2014 16:28:03 +0100 Subject: [PATCH] Support for the SDK 8.0 (scanning for bootloader with differnt address) --- res/values/strings.xml | 2 + .../android/dfu/DfuBaseService.java | 256 ++++++++++++++++-- .../dfu/scanner/BootloaderScanner.java | 31 +++ .../dfu/scanner/BootloaderScannerFactory.java | 17 ++ .../dfu/scanner/BootloaderScannerJB.java | 76 ++++++ .../scanner/BootloaderScannerLollipop.java | 89 ++++++ 6 files changed, 447 insertions(+), 24 deletions(-) create mode 100644 src/no/nordicsemi/android/dfu/scanner/BootloaderScanner.java create mode 100644 src/no/nordicsemi/android/dfu/scanner/BootloaderScannerFactory.java create mode 100644 src/no/nordicsemi/android/dfu/scanner/BootloaderScannerJB.java create mode 100644 src/no/nordicsemi/android/dfu/scanner/BootloaderScannerLollipop.java diff --git a/res/values/strings.xml b/res/values/strings.xml index a9975f1..bc8e95d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -7,6 +7,7 @@ Initializing… Connecting… Starting DFU… + Starting bootloader… Uploading… Uploading part %d/%d… Validating… @@ -18,6 +19,7 @@ Connecting to %s… Initializing DFU process… + Waiting for bootloader… Transmitting components to %s… Transmitting application to %s… Validating… diff --git a/src/no/nordicsemi/android/dfu/DfuBaseService.java b/src/no/nordicsemi/android/dfu/DfuBaseService.java index 5550ee9..841b4a1 100644 --- a/src/no/nordicsemi/android/dfu/DfuBaseService.java +++ b/src/no/nordicsemi/android/dfu/DfuBaseService.java @@ -23,11 +23,14 @@ import no.nordicsemi.android.dfu.exception.HexFileValidationException; import no.nordicsemi.android.dfu.exception.RemoteDfuException; import no.nordicsemi.android.dfu.exception.UnknownResponseException; import no.nordicsemi.android.dfu.exception.UploadAbortedException; +import no.nordicsemi.android.dfu.scanner.BootloaderScanner; +import no.nordicsemi.android.dfu.scanner.BootloaderScannerFactory; import no.nordicsemi.android.error.GattError; import no.nordicsemi.android.log.ILogSession; import no.nordicsemi.android.log.LogContract; import no.nordicsemi.android.log.LogContract.Log.Level; import no.nordicsemi.android.log.Logger; +import android.annotation.SuppressLint; import android.app.Activity; import android.app.IntentService; import android.app.NotificationManager; @@ -45,10 +48,9 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.Color; import android.net.Uri; +import android.os.Build; import android.os.SystemClock; import android.preference.PreferenceManager; import android.support.v4.app.NotificationCompat; @@ -86,8 +88,24 @@ public abstract class DfuBaseService extends IntentService { /** A key for {@link SharedPreferences} entry that keeps information whether the upload is currently in progress. This may be used to get this information during activity creation. */ public static final String DFU_IN_PROGRESS = "no.nordicsemi.android.dfu.PREFS_DFU_IN_PROGRESS"; + /** The address of the device to update. */ public static final String EXTRA_DEVICE_ADDRESS = "no.nordicsemi.android.dfu.extra.EXTRA_DEVICE_ADDRESS"; + /** The optional device name. This name will be shown in the notification. */ public static final String EXTRA_DEVICE_NAME = "no.nordicsemi.android.dfu.extra.EXTRA_DEVICE_NAME"; + /** + *

+ * If the new firmware does not share the bond information with the old one the bond information is lost. Set this flag to true to make the service create new bond with the new + * application when the upload is done (and remove the old one). When set to false (default), the DFU service assumes that the LTK is shared between them. Currently it is not possible + * to remove the old bond and not creating a new one so if your old application supported bonding while the new one does not you have to modify the source code yourself. + *

+ *

+ * In case of updating the soft device and bootloader the application is always removed so the bond information with it. + *

+ *

+ * Search for occurrences of EXTRA_RESTORE_BOND in this file to check the implementation and get more details. + *

+ */ + public static final String EXTRA_RESTORE_BOND = "no.nordicsemi.android.dfu.extra.EXTRA_RESTORE_BOND"; public static final String EXTRA_LOG_URI = "no.nordicsemi.android.dfu.extra.EXTRA_LOG_URI"; public static final String EXTRA_FILE_PATH = "no.nordicsemi.android.dfu.extra.EXTRA_FILE_PATH"; public static final String EXTRA_FILE_URI = "no.nordicsemi.android.dfu.extra.EXTRA_FILE_URI"; @@ -185,6 +203,7 @@ public abstract class DfuBaseService extends IntentService { *