Commit a6baf80e authored by Tobias Wich's avatar Tobias Wich
Browse files

Call card insert and recognised handler if card is already present when starting handler

parent 0612de3e
......@@ -42,7 +42,9 @@ import;
import org.openecard.common.event.EventObject;
import org.openecard.common.event.EventType;
import org.openecard.common.event.IfdEventObject;
import org.openecard.common.interfaces.EventCallback;
import org.openecard.common.sal.state.CardStateEntry;
import org.openecard.common.util.CombinedPromise;
import org.openecard.common.util.Promise;
......@@ -144,6 +146,14 @@ public abstract class AbstractActivationHandler <T extends Activity, GUI extends
// add callback to this abstract activity when card is removed
cardRecognized = false;
// check card states for already inserted card and call recognised handler
CardStateEntry availableCard = getAvailableCard();
if (availableCard != null) {
insertionHandler.signalEvent(EventType.CARD_INSERTED, new IfdEventObject(availableCard.handleCopy()));
cardDetectHandler.signalEvent(EventType.RECOGNIZED_CARD_ACTIVE, new IfdEventObject(availableCard.handleCopy()));
octx.getEventDispatcher().add(insertionHandler, EventType.CARD_REMOVED, EventType.CARD_INSERTED);
octx.getEventDispatcher().add(cardDetectHandler, EventType.RECOGNIZED_CARD_ACTIVE);
octx.getEventDispatcher().add(removalHandler, EventType.CARD_REMOVED);
......@@ -168,6 +178,27 @@ public abstract class AbstractActivationHandler <T extends Activity, GUI extends
private CardStateEntry getAvailableCard() {
// look in card states for a card matching our criteria
Set<String> types = getSupportedCards();
if (types != null) {
for (String type : types) {
ConnectionHandleType query = new ConnectionHandleType();
ConnectionHandleType.RecognitionInfo rinfo = new ConnectionHandleType.RecognitionInfo();
CardStateEntry entry = octx.getCardStates().getEntry(query);
if (entry != null) {
return entry;
return null;
} else {
return octx.getCardStates().getEntry(new ConnectionHandleType());
private Class<?> forClassName(@Nullable String className) {
if (className != null) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment