diff --git a/app/build.gradle b/app/build.gradle index eda6fc55..d24500ca 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -49,7 +49,7 @@ dependencies { implementation 'no.nordicsemi.android.support.v18:scanner:1.0.0' // The DFU Library is imported automatically from jcenter: - implementation 'no.nordicsemi.android:dfu:1.5.1' + implementation 'no.nordicsemi.android:dfu:1.5.2' // if you desire to build the DFU Library, clone the https://github.com/NordicSemiconductor/Android-DFU-Library project into DFULibrary folder, // add it as a module into the project structure and uncomment the following line (and also the according lines in the settings.gradle): // implementation project(':dfu') diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/dfu/DfuActivity.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/dfu/DfuActivity.java index 3c60fc22..00179f8a 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/dfu/DfuActivity.java +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/dfu/DfuActivity.java @@ -90,6 +90,7 @@ public class DfuActivity extends AppCompatActivity implements LoaderCallbacks { - mInitFilePath = null; - mInitFileStreamUri = null; - }).setPositiveButton(R.string.yes, (dialog, which) -> { - final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); - intent.setType(DfuService.MIME_TYPE_OCTET_STREAM); - intent.addCategory(Intent.CATEGORY_OPENABLE); - startActivityForResult(intent, SELECT_INIT_FILE_REQ); - }).show(); + if (statusOk) { + if (fileType != DfuService.TYPE_AUTO) { + mScope = null; + mFileScopeView.setText(getString(R.string.not_available)); + new AlertDialog.Builder(this).setTitle(R.string.dfu_file_init_title).setMessage(R.string.dfu_file_init_message) + .setNegativeButton(R.string.no, (dialog, which) -> { + mInitFilePath = null; + mInitFileStreamUri = null; + }).setPositiveButton(R.string.yes, (dialog, which) -> { + final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setType(DfuService.MIME_TYPE_OCTET_STREAM); + intent.addCategory(Intent.CATEGORY_OPENABLE); + startActivityForResult(intent, SELECT_INIT_FILE_REQ); + }).show(); + } else { + new AlertDialog.Builder(this).setTitle(R.string.dfu_file_scope_title).setCancelable(false) + .setSingleChoiceItems(R.array.dfu_file_scope, 0, (dialog, which) -> { + switch (which) { + case 0: + mScope = null; + break; + case 1: + mScope = DfuServiceInitiator.SCOPE_SYSTEM_COMPONENTS; + break; + case 2: + mScope = DfuServiceInitiator.SCOPE_APPLICATION; + break; + } + }).setPositiveButton(R.string.ok, (dialogInterface, i) -> { + int index; + if (mScope == null) { + index = 0; + } else if (mScope == DfuServiceInitiator.SCOPE_SYSTEM_COMPONENTS) { + index = 1; + } else { + index = 2; + } + mFileScopeView.setText(getResources().getStringArray(R.array.dfu_file_scope)[index]); + }).show(); + } } } @@ -680,6 +717,7 @@ public class DfuActivity extends AppCompatActivity implements LoaderCallbacks + + + + + + + @@ -173,7 +190,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/feature_section_padding" - android:layout_marginTop="4dp" android:gravity="center_vertical" android:orientation="horizontal" android:paddingLeft="42dp"> @@ -200,7 +216,7 @@ android:id="@+id/dfu_pane" style="@style/Widget.List" android:layout_width="0dp" - android:layout_height="160dp" + android:layout_height="176dp" android:layout_marginBottom="8dp" android:layout_marginLeft="14dp" android:layout_marginRight="4dp" @@ -254,8 +270,7 @@ diff --git a/app/src/main/res/layout-sw600dp-land/activity_feature_dfu.xml b/app/src/main/res/layout-sw600dp-land/activity_feature_dfu.xml index e437a759..e0bfeb81 100644 --- a/app/src/main/res/layout-sw600dp-land/activity_feature_dfu.xml +++ b/app/src/main/res/layout-sw600dp-land/activity_feature_dfu.xml @@ -126,6 +126,23 @@ android:freezesText="true"/> + + + + + + + diff --git a/app/src/main/res/layout/activity_feature_dfu.xml b/app/src/main/res/layout/activity_feature_dfu.xml index 3a86bed8..394fa3ba 100644 --- a/app/src/main/res/layout/activity_feature_dfu.xml +++ b/app/src/main/res/layout/activity_feature_dfu.xml @@ -148,6 +148,23 @@ android:freezesText="true"/> + + + + + + + diff --git a/app/src/main/res/values/strings_dfu.xml b/app/src/main/res/values/strings_dfu.xml index ab0285bf..334c0e39 100644 --- a/app/src/main/res/values/strings_dfu.xml +++ b/app/src/main/res/values/strings_dfu.xml @@ -24,7 +24,7 @@ DFU nRF Toolbox DFU Proxy DFU Settings - DFU Library version 1.5.1 + DFU Library version 1.5.2 DEVICE FIRMWARE UPDATE -186dp @@ -34,9 +34,10 @@ DFU script files were copied to /sdcard/Nordic Semiconductor. APPLICATION - File Name: - File Type: - File Size: + File name: + Type: + Size: + Scope: Status: %d bytes OK @@ -83,7 +84,7 @@ During a DFU operation a lot of data packets are being sent to the target. The onCharacteristicWrite(...) callback in Android API is invoked when the data has been written to the outgoing queue, not when physically sent. Packet receipt notifications were introduced to prevent from overflowing the queue. Depending on the device model, disabling the notifications or setting the value to “high” (> ~300) may make the DFU process freeze - at some point. + at some point on Android versions before Marshmallow. Select file type @@ -97,6 +98,12 @@ The Init packet file (*.dat) should contain the device type and revision, application version, list of supported Soft Devices and the firmware CRC in binary format or, with old versions of the DFU bootloader, only the CRC (CRC-CCITT-16). With the new version of the bootloader the extended Init packet is required. + Select scope + + All + System components only + Application only + unnamed device 0% @@ -110,7 +117,7 @@ Select file A file browser application must be installed on the device before selecting the file. \n\nThere are number of applications available on Google Play store, e.g. Total Commander or File Manager, that allow you to pick a file from internal memory of the device. To upload - a file from the Internet you may use f.e. Drive or Dropbox application. + a file from the Internet you may use e.g. Drive or Dropbox application. \n\nYou will be asked to select an application if more than one is installed. A single application will be launched automatically. \n\nSince Android KitKat you may use the preinstalled document picker application. Ensure Display advanced devices option is enabled in settings to use the Internal storage. \n\nSample applications were copied to Nordic Semiconductor folder in the internal storage. diff --git a/app/src/main/res/xml-v23/settings_dfu.xml b/app/src/main/res/xml-v23/settings_dfu.xml new file mode 100644 index 00000000..0a29b128 --- /dev/null +++ b/app/src/main/res/xml-v23/settings_dfu.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file