+++ /dev/null
-/*
- * IntercardReader.java
- *
- * Copyright (C) 2014 Jakob Wenzel
- *
- * Authors:
- * Jakob Wenzel <jakobwenzel92@gmail.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package de.dhbwloe.campusapp.nfcreader.cardreader;
-
-import android.os.Bundle;
-import android.util.Log;
-
-import com.codebutler.farebot.Utils;
-import com.codebutler.farebot.card.desfire.DesfireException;
-import com.codebutler.farebot.card.desfire.DesfireFileSettings;
-import com.codebutler.farebot.card.desfire.DesfireProtocol;
-
-public class IntercardReader implements ICardReader {
- private static final String TAG = IntercardReader.class.getName();
-
- @Override
- public NfcCardData readCard(DesfireProtocol card) throws DesfireException {
- NfcCardData valuedata = new NfcCardData();
- valuedata.setUniqueId(card.getManufacturingData().uid);
-
- try {
- int[] appList = card.getAppList();
- for(int i = 0; i < appList.length; i++) {
- for(int j = 0; j < 10; j++) {
- try {
- DesfireFileSettings settings = Utils.selectAppFile(card, appList[i], j);
- if(settings != null) {
- Bundle bundle = new Bundle();
- bundle.putString("type", settings.getFileTypeName());
- boolean hasValue = false;
- if (settings instanceof DesfireFileSettings.ValueDesfireFileSettings) {
- DesfireFileSettings.ValueDesfireFileSettings value = (DesfireFileSettings.ValueDesfireFileSettings) settings;
- bundle.putInt("value", value.value);
- hasValue = true;
- bundle.putByte("limited", value.limitedCreditEnabled);
- bundle.putInt("max", value.upperLimit);
- bundle.putInt("min", value.lowerLimit);
- } else if (settings instanceof DesfireFileSettings.StandardDesfireFileSettings) {
- DesfireFileSettings.StandardDesfireFileSettings value = (DesfireFileSettings.StandardDesfireFileSettings) settings;
- bundle.putInt("size", value.fileSize);
- } else if (settings instanceof DesfireFileSettings.RecordDesfireFileSettings) {
- DesfireFileSettings.RecordDesfireFileSettings value = (DesfireFileSettings.RecordDesfireFileSettings) settings;
- bundle.putInt("records", value.curRecords);
- bundle.putInt("size", value.recordSize);
- bundle.putInt("max", value.maxRecords);
- hasValue = true;
- }
-
- try {
- bundle.putInt("data", card.readValue(j));
- hasValue = true;
-
- } catch (Exception e) {
- }
- try {
- byte[] bytes = card.readFile(j);
- bundle.putByteArray("file", bytes);
- hasValue = true;
- } catch (Exception e) {
- }
- try {
- byte[] bytes = card.readRecord(j);
- bundle.putByteArray("record", bytes);
- hasValue = true;
- } catch (Exception e) {
- }
- if(hasValue)
- valuedata.appendPlainData(appList[i], j, bundle);
- }
- } catch (Exception e) {
- break;
- }
- }
-
- }
- } catch (Exception e) {
- }
- return valuedata;
- }
-}