Merge branch 'release'
This commit is contained in:
commit
c298beb292
|
@ -107,6 +107,10 @@ public abstract class DfuBaseService extends IntentService {
|
|||
* 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";
|
||||
/**
|
||||
* A boolean indicating whether to disable the progress notification in the status bar. Defaults to false.
|
||||
*/
|
||||
public static final String EXTRA_DISABLE_NOTIFICATION = "no.nordicsemi.android.dfu.extra.EXTRA_DISABLE_NOTIFICATION";
|
||||
/**
|
||||
* <p>
|
||||
* If the new firmware (application) does not share the bond information with the old one, the bond information is lost. Set this flag to <code>true</code>
|
||||
|
@ -548,6 +552,7 @@ public abstract class DfuBaseService extends IntentService {
|
|||
private InputStream mInputStream;
|
||||
private String mDeviceAddress;
|
||||
private String mDeviceName;
|
||||
private boolean mDisableNotification;
|
||||
/**
|
||||
* The current connection state. If its value is > 0 than an error has occurred. Error number is a negative value of mConnectionState
|
||||
*/
|
||||
|
@ -1082,6 +1087,7 @@ public abstract class DfuBaseService extends IntentService {
|
|||
// Read input parameters
|
||||
final String deviceAddress = intent.getStringExtra(EXTRA_DEVICE_ADDRESS);
|
||||
final String deviceName = intent.getStringExtra(EXTRA_DEVICE_NAME);
|
||||
final boolean disableNotification = intent.getBooleanExtra(EXTRA_DISABLE_NOTIFICATION, false);
|
||||
final String filePath = intent.getStringExtra(EXTRA_FILE_PATH);
|
||||
final Uri fileUri = intent.getParcelableExtra(EXTRA_FILE_URI);
|
||||
final int fileResId = intent.getIntExtra(EXTRA_FILE_RES_ID, 0);
|
||||
|
@ -1112,6 +1118,7 @@ public abstract class DfuBaseService extends IntentService {
|
|||
|
||||
mDeviceAddress = deviceAddress;
|
||||
mDeviceName = deviceName;
|
||||
mDisableNotification = disableNotification;
|
||||
mConnectionState = STATE_DISCONNECTED;
|
||||
mBytesSent = 0;
|
||||
mBytesConfirmed = 0;
|
||||
|
@ -2699,6 +2706,16 @@ public abstract class DfuBaseService extends IntentService {
|
|||
* {@link #PROGRESS_VALIDATING}, {@link #PROGRESS_DISCONNECTING}, {@link #PROGRESS_COMPLETED} or {@link #ERROR_FILE_ERROR}, {@link #ERROR_FILE_INVALID} , etc
|
||||
*/
|
||||
private void updateProgressNotification(final int progress) {
|
||||
|
||||
// send progress or error broadcast
|
||||
if (progress < ERROR_MASK)
|
||||
sendProgressBroadcast(progress);
|
||||
else
|
||||
sendErrorBroadcast(progress);
|
||||
|
||||
if (mDisableNotification) return;
|
||||
// create or update notification:
|
||||
|
||||
final String deviceAddress = mDeviceAddress;
|
||||
final String deviceName = mDeviceName != null ? mDeviceName : getString(R.string.dfu_unknown_name);
|
||||
|
||||
|
@ -2746,11 +2763,6 @@ public abstract class DfuBaseService extends IntentService {
|
|||
builder.setOngoing(true).setContentTitle(title).setContentText(text).setProgress(100, progress, false);
|
||||
}
|
||||
}
|
||||
// send progress or error broadcast
|
||||
if (progress < ERROR_MASK)
|
||||
sendProgressBroadcast(progress);
|
||||
else
|
||||
sendErrorBroadcast(progress);
|
||||
|
||||
// update the notification
|
||||
final Intent intent = new Intent(this, getNotificationTarget());
|
||||
|
|
|
@ -38,6 +38,8 @@ public class DfuServiceInitiator {
|
|||
private final String deviceAddress;
|
||||
private String deviceName;
|
||||
|
||||
private boolean disableNotification;
|
||||
|
||||
private Uri fileUri;
|
||||
private String filePath;
|
||||
private int fileResId;
|
||||
|
@ -71,6 +73,17 @@ public class DfuServiceInitiator {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the progress notification in the status bar should be disabled.
|
||||
* Defaults to false.
|
||||
* @param disableNotification whether to disable the notification
|
||||
* @return the builder
|
||||
*/
|
||||
public DfuServiceInitiator setDisableNotification(final boolean disableNotification) {
|
||||
this.disableNotification = disableNotification;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -245,6 +258,7 @@ public class DfuServiceInitiator {
|
|||
|
||||
intent.putExtra(DfuBaseService.EXTRA_DEVICE_ADDRESS, deviceAddress);
|
||||
intent.putExtra(DfuBaseService.EXTRA_DEVICE_NAME, deviceName);
|
||||
intent.putExtra(DfuBaseService.EXTRA_DISABLE_NOTIFICATION, disableNotification);
|
||||
intent.putExtra(DfuBaseService.EXTRA_FILE_MIME_TYPE, mimeType);
|
||||
intent.putExtra(DfuBaseService.EXTRA_FILE_TYPE, fileType);
|
||||
intent.putExtra(DfuBaseService.EXTRA_FILE_URI, fileUri);
|
||||
|
|
Loading…
Reference in New Issue