diff --git a/Laerdal.McuMgr.Bindings.Android.Native/mcumgr-laerdal-wrapper/src/main/java/no/laerdal/mcumgr_laerdal_wrapper/AndroidFileUploader.java b/Laerdal.McuMgr.Bindings.Android.Native/mcumgr-laerdal-wrapper/src/main/java/no/laerdal/mcumgr_laerdal_wrapper/AndroidFileUploader.java index 0bb1fe77..3083ae7d 100644 --- a/Laerdal.McuMgr.Bindings.Android.Native/mcumgr-laerdal-wrapper/src/main/java/no/laerdal/mcumgr_laerdal_wrapper/AndroidFileUploader.java +++ b/Laerdal.McuMgr.Bindings.Android.Native/mcumgr-laerdal-wrapper/src/main/java/no/laerdal/mcumgr_laerdal_wrapper/AndroidFileUploader.java @@ -42,7 +42,7 @@ public AndroidFileUploader(@NonNull final Context context, @NonNull final Blueto public boolean trySetContext(@NonNull final Context context) { - if (!IsCold()) + if (!IsIdleOrCold()) return false; if (!tryInvalidateCachedTransport()) //order @@ -54,11 +54,19 @@ public boolean trySetContext(@NonNull final Context context) public boolean trySetBluetoothDevice(@NonNull final BluetoothDevice bluetoothDevice) { - if (!IsCold()) + logMessageAdvertisement("[AFU.TSBD.000] trySetBluetoothDevice() called", "FileUploader", "TRACE", _remoteFilePathSanitized); + + if (!IsIdleOrCold()) { + logMessageAdvertisement("[AFU.TSBD.005] trySetBluetoothDevice() cannot proceed because the uploader is not cold", "FileUploader", "TRACE", _remoteFilePathSanitized); return false; + } + logMessageAdvertisement("[AFU.TSBD.010]", "FileUploader", "TRACE", _remoteFilePathSanitized); if (!tryInvalidateCachedTransport()) //order + { + logMessageAdvertisement("[AFU.TSBD.020]", "FileUploader", "TRACE", _remoteFilePathSanitized); return false; + } _bluetoothDevice = bluetoothDevice; //order @@ -72,7 +80,7 @@ public boolean tryInvalidateCachedTransport() if (_transport == null) //already scrapped return true; - if (!IsCold()) //if the upload is already in progress we bail out + if (!IsIdleOrCold()) //if the upload is already in progress we bail out return false; disposeFilesystemManager(); // order @@ -363,6 +371,12 @@ private void setState(final EAndroidFileUploaderState newState) //00 trivial hotfix to deal with the fact that the file-upload progress% doesn't fill up to 100% } + @Contract(pure = true) + private boolean IsIdleOrCold() + { + return _currentState == EAndroidFileUploaderState.IDLE || IsCold(); + } + @Contract(pure = true) private boolean IsCold() {