mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-24 10:56:50 +01:00
Make update notification dismissable on error conditions
good idea, @joserebelo #821
This commit is contained in:
parent
976942757f
commit
32d5ceb78f
@ -91,6 +91,18 @@ public class UpdateFirmwareOperation extends AbstractMiBand2Operation {
|
||||
unsetBusy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
||||
if (status != BluetoothGatt.GATT_SUCCESS) {
|
||||
operationFailed();
|
||||
}
|
||||
return super.onCharacteristicWrite(gatt, characteristic, status);
|
||||
}
|
||||
|
||||
private void operationFailed() {
|
||||
GB.updateInstallNotification(getContext().getString(R.string.updatefirmwareoperation_write_failed), false, 0, getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCharacteristicChanged(BluetoothGatt gatt,
|
||||
BluetoothGattCharacteristic characteristic) {
|
||||
@ -154,6 +166,7 @@ public class UpdateFirmwareOperation extends AbstractMiBand2Operation {
|
||||
default: {
|
||||
LOG.error("Unexpected response during firmware update: ");
|
||||
getSupport().logMessageContent(value);
|
||||
operationFailed();
|
||||
displayMessage(getContext(), getContext().getString(R.string.updatefirmwareoperation_updateproblem_do_not_reboot), Toast.LENGTH_LONG, GB.ERROR);
|
||||
done();
|
||||
return;
|
||||
@ -165,6 +178,7 @@ public class UpdateFirmwareOperation extends AbstractMiBand2Operation {
|
||||
}
|
||||
} else {
|
||||
LOG.error("Unexpected notification during firmware update: ");
|
||||
operationFailed();
|
||||
getSupport().logMessageContent(value);
|
||||
displayMessage(getContext(), getContext().getString(R.string.updatefirmwareoperation_metadata_updateproblem), Toast.LENGTH_LONG, GB.ERROR);
|
||||
done();
|
||||
|
Loading…
Reference in New Issue
Block a user