Skip to content

Commit

Permalink
Fix exception handling on SAM Switch To AV2 tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxhy committed Oct 18, 2023
1 parent ef39b55 commit fe34f78
Showing 1 changed file with 11 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,11 @@ public SAMKeyStoreToolsControlViewModel()
LibLogicalAccess.Card.SAMLockUnlock.SwitchAV2Mode
});

SAMAuthCommand = new RelayCommand(
() =>
{
SAMAuthenticate();
});

SAMSwitchAV2Command = new RelayCommand(
() =>
{
SAMSwitchAV2();
});

SAMLockUnlockCommand = new RelayCommand(
() =>
{
SAMLockUnlock();
});

SAMGetVersionCommand = new RelayCommand(
() =>
{
SAMGetVersion();
});

SAMActivateMifareSAMCommand = new RelayCommand(
() =>
{
SAMActivateMifareSAM();
});
SAMAuthCommand = new RelayCommand(SAMAuthenticate);
SAMSwitchAV2Command = new AsyncRelayCommand(SAMSwitchAV2);
SAMLockUnlockCommand = new RelayCommand(SAMLockUnlock);
SAMGetVersionCommand = new RelayCommand(SAMGetVersion);
SAMActivateMifareSAMCommand = new RelayCommand(SAMActivateMifareSAM);
}

private KeyVersion _samAuthKey;
Expand Down Expand Up @@ -107,7 +83,7 @@ public LibLogicalAccess.Card.SAMLockUnlock SAMUnlockAction

public RelayCommand SAMAuthCommand { get; }

public RelayCommand SAMSwitchAV2Command { get; }
public AsyncRelayCommand SAMSwitchAV2Command { get; }

public RelayCommand SAMLockUnlockCommand { get; }

Expand Down Expand Up @@ -197,15 +173,18 @@ private void SAMAuthenticate()
}
}

private void SAMSwitchAV2()
private async Task SAMSwitchAV2()
{
try
{
var ks = (KeyStore as SAMKeyStore);
var cmd = ks?.Chip?.getCommands();
if (cmd is SAMAV1ISO7816Commands samav1cmd)
{
ks?.SwitchSAMToAV2(samav1cmd);
if (ks != null)
{
await ks.SwitchSAMToAV2(samav1cmd);
}
SnackbarHelper.EnqueueMessage(SnackbarMessageQueue, "SAM Switch to AV2 succeeded!");
}
else if (cmd is SAMAV2ISO7816Commands samav2cmd)
Expand Down

0 comments on commit fe34f78

Please sign in to comment.