Skip to content

Commit

Permalink
fix (AndroidFileUploader.java): fix a bug in trySetBluetoothDevice() …
Browse files Browse the repository at this point in the history
…which was causing it to refuse the call when state=idle
  • Loading branch information
ksidirop-laerdal committed Oct 15, 2024
1 parent 7e67db0 commit 793671e
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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()
{
Expand Down

0 comments on commit 793671e

Please sign in to comment.