Skip to content

Commit

Permalink
clean (AndroidDeviceResetter.java): trivial neutral simplifications o…
Browse files Browse the repository at this point in the history
…n corner-case errors
  • Loading branch information
ksidirop-laerdal committed Oct 31, 2024
1 parent 0971c23 commit 95f26f5
Showing 1 changed file with 24 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,43 +37,35 @@ public void beginReset()
try
{
_manager = new DefaultManager(_transport);
}
catch (final Exception ex)
{
setState(EAndroidDeviceResetterState.FAILED);
onError("Failed to create manager: '" + ex.getMessage() + "'", ex);
return;
}

setState(EAndroidDeviceResetterState.RESETTING);
setState(EAndroidDeviceResetterState.RESETTING);

AndroidDeviceResetter self = this;

_manager.reset(new McuMgrCallback<McuMgrOsResponse>()
{
@Override
public void onResponse(@NotNull final McuMgrOsResponse response)
AndroidDeviceResetter self = this;
_manager.reset(new McuMgrCallback<McuMgrOsResponse>()
{
if (!response.isSuccess())
{ // check for an error return code
self.onError("Reset failed (error-code '" + response.getReturnCode().toString() + "')", response.getReturnCode(), response.getGroupReturnCode());

setState(EAndroidDeviceResetterState.FAILED);
return;
@Override
public void onResponse(@NotNull final McuMgrOsResponse response)
{
if (!response.isSuccess())
{ // check for an error return code
self.onError("[ADR.BR.002] Reset failed (error-code '" + response.getReturnCode().toString() + "')", response.getReturnCode(), response.getGroupReturnCode());
return;
}

setState(EAndroidDeviceResetterState.COMPLETE);
}

setState(EAndroidDeviceResetterState.COMPLETE);
}

@Override
public void onError(@NotNull final McuMgrException exception)
{
self.onError("Reset failed '" + exception.getMessage() + "'", exception);

setState(EAndroidDeviceResetterState.FAILED);
}

});
@Override
public void onError(@NotNull final McuMgrException exception)
{
self.onError("[ADR.BR.005] Reset failed '" + exception.getMessage() + "'", exception);
}
});
}
catch (final Exception ex)
{
onError("[ADR.BR.010] Failed to initialize reset operation: '" + ex.getMessage() + "'", ex);
}
}

public void disconnect()
Expand Down

0 comments on commit 95f26f5

Please sign in to comment.