Browse Source

Added more APDU commands

hbw_build
Wong Joon Hui 2 years ago
parent
commit
0d9559a078
  1. 1
      .idea/.name
  2. 2
      .idea/misc.xml
  3. 2
      app/build.gradle
  4. 26
      app/src/androidTest/java/com/cst/im30/ExampleInstrumentedTest.java
  5. 18
      app/src/main/AndroidManifest.xml
  6. 277
      app/src/main/java/com/cst/im30/activity/ICCActivity.java
  7. 22
      app/src/main/java/com/cst/im30/model/NRICData.java
  8. 693
      app/src/main/java/com/cst/im30/utility/NRICApduUtils.java
  9. 46
      app/src/main/res/layout/confirm_read.xml
  10. 17
      app/src/test/java/com/cst/im30/ExampleUnitTest.java
  11. 2
      settings.gradle

1
.idea/.name

@ -0,0 +1 @@
pax_kiosk_im30

2
.idea/misc.xml

@ -35,6 +35,8 @@
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/layout/pop_up_notification.xml" value="0.3546875" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" value="0.3295" />
<entry key="..\:/StudioProjects/kiosk-im30/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" value="0.37083333333333335" />
<entry key="..\:/StudioProjects/pax_kiosk-im30/app/src/main/res/layout/confirm.xml" value="0.1765625" />
<entry key="..\:/StudioProjects/pax_kiosk-im30/app/src/main/res/layout/confirm_read.xml" value="0.3546875" />
</map>
</option>
</component>

2
app/build.gradle

@ -7,7 +7,7 @@ android {
defaultConfig {
applicationId "com.cst.im30"
minSdkVersion 25
minSdkVersion 22
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 28
versionCode 5

26
app/src/androidTest/java/com/cst/im30/ExampleInstrumentedTest.java

@ -1,26 +0,0 @@
package com.cst.im30;
import static org.junit.Assert.assertEquals;
import android.content.Context;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.cst.im30", appContext.getPackageName());
}
}

18
app/src/main/AndroidManifest.xml

@ -27,14 +27,7 @@
<activity
android:name="com.cst.im30.activity.ICCActivity"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<activity
android:name="com.cst.im30.activity.MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
tools:ignore="LockedOrientationActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -46,6 +39,15 @@
</intent-filter>
</activity>
<activity
android:name="com.cst.im30.activity.MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
</activity>
<activity
android:name="com.cst.im30.activity.ResponseActivity"
android:exported="true"

277
app/src/main/java/com/cst/im30/activity/ICCActivity.java

@ -5,15 +5,17 @@ import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable;
@ -22,6 +24,7 @@ import androidx.appcompat.app.AppCompatActivity;
import com.cst.im30.MainApplication;
import com.cst.im30.R;
import com.cst.im30.model.NRICData;
import com.cst.im30.utility.IccTester;
import com.cst.im30.utility.Logger;
import com.cst.im30.utility.NRICApduUtils;
@ -30,8 +33,6 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;
@ -54,109 +55,139 @@ public class ICCActivity extends AppCompatActivity {
public void handleMessage(Message msg) {
switch (msg.what) {
case 0: //got card
iccDetectedThread.interrupt();
ArrayList<String> info = (ArrayList<String>) msg.obj;
if (info.get(0).trim().equals("")) {
pd.dismiss();
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ICCActivity.this);
LayoutInflater inflater = (LayoutInflater) ICCActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView = inflater.inflate(R.layout.confirm, null);
TextView textMessage = dialogView.findViewById(R.id.text_message_confirm);
TextView textTitle = dialogView.findViewById(R.id.text_title_confirm);
textTitle.setText("Error");
textMessage.setText("Cannot read card / Invalid card.\nPlease try again.");
dialogBuilder.setPositiveButton("OK", (dialog, which) -> {
stopChecking = false;
insertCard();
});
dialogBuilder.setCancelable(false);
dialogBuilder.setView(dialogView);
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();
} else {
name = info.get(1).trim();
cardNo = info.get(0).trim();
handlerGotCardHandler(msg);
break;
case 1: //no card
handlerNoCardHandler(msg);
break;
case 2: //invalid card
handlerInvalidCard(msg);
break;
default:
break;
}
}
};
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ICCActivity.this);
LayoutInflater inflater = (LayoutInflater) ICCActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView = inflater.inflate(R.layout.confirm, null);
@SuppressLint("SetTextI18n")
private void handlerGotCardHandler(Message msg) {
iccDetectedThread.interrupt();
NRICData nricData = (NRICData) msg.obj;
TextView textMessage = dialogView.findViewById(R.id.text_message_confirm);
TextView textTitle = dialogView.findViewById(R.id.text_title_confirm);
String cardNo = nricData.getNric();
String name = nricData.getFinalName();
textTitle.setText("Read Success");
textMessage.setText("Please remove card.");
if (cardNo.trim().equals("")) {
onGotCardCannotReadCard();
} else {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ICCActivity.this);
LayoutInflater inflater = (LayoutInflater) ICCActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView = inflater.inflate(R.layout.confirm_read, null);
dialogBuilder.setCancelable(false);
dialogBuilder.setView(dialogView);
TextView textTitle = dialogView.findViewById(R.id.text_title_confirm);
ImageView imageView = dialogView.findViewById(R.id.image_view);
TextView textMessage = dialogView.findViewById(R.id.text_message);
TextView textConfirm = dialogView.findViewById(R.id.text_message_confirm);
alertDialogPromptCard = dialogBuilder.create();
alertDialogPromptCard.show();
textTitle.setText("Read Success");
checkCard();
}
break;
case 1: //no card
iccDetectedThread.interrupt();
pd.dismiss();
Bitmap bmp = BitmapFactory.decodeByteArray(nricData.getPhoto(), 0, nricData.getPhoto().length);
imageView.setImageBitmap(bmp);
AlertDialog.Builder dialogBuilder1 = new AlertDialog.Builder(ICCActivity.this);
LayoutInflater inflater1 = (LayoutInflater) ICCActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView1 = inflater1.inflate(R.layout.confirm, null);
String message = "";
message += nricData.getNric() + "\n" + nricData.getFinalName();
textMessage.setText(message);
TextView textMessage1 = dialogView1.findViewById(R.id.text_message_confirm);
TextView textTitle1 = dialogView1.findViewById(R.id.text_title_confirm);
imageView.setVisibility(View.VISIBLE);
textMessage.setVisibility(View.VISIBLE);
textTitle1.setText("Error");
textMessage1.setText("No card detected. Please insert card to read.");
textConfirm.setText("Please remove card.");
dialogBuilder1.setPositiveButton("OK", (dialog, which) -> {
stopChecking = false;
insertCard();
});
dialogBuilder1.setCancelable(false);
dialogBuilder1.setView(dialogView1);
dialogBuilder.setCancelable(false);
dialogBuilder.setView(dialogView);
AlertDialog alertDialog1 = dialogBuilder1.create();
alertDialog1.show();
alertDialogPromptCard = dialogBuilder.create();
alertDialogPromptCard.show();
break;
checkCard();
}
}
case 2: //invalid card
iccDetectedThread.interrupt();
pd.dismiss();
@SuppressLint("SetTextI18n")
private void onGotCardCannotReadCard() {
pd.dismiss();
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ICCActivity.this);
LayoutInflater inflater = (LayoutInflater) ICCActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView = inflater.inflate(R.layout.confirm, null);
AlertDialog.Builder dialogBuilder2 = new AlertDialog.Builder(ICCActivity.this);
LayoutInflater inflater2 = (LayoutInflater) ICCActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView2 = inflater2.inflate(R.layout.confirm, null);
TextView textMessage = dialogView.findViewById(R.id.text_message_confirm);
TextView textTitle = dialogView.findViewById(R.id.text_title_confirm);
TextView textMessage2 = dialogView2.findViewById(R.id.text_message_confirm);
TextView textTitle2 = dialogView2.findViewById(R.id.text_title_confirm);
textTitle.setText("Error");
textMessage.setText("Cannot read card / Invalid card.\nPlease try again.");
textTitle2.setText("Error");
textMessage2.setText(msg.obj.toString());
dialogBuilder.setPositiveButton("OK", (dialog, which) -> {
stopChecking = false;
insertCard();
});
dialogBuilder.setCancelable(false);
dialogBuilder.setView(dialogView);
dialogBuilder2.setPositiveButton("OK", (dialog, which) -> {
stopChecking = false;
insertCard();
});
dialogBuilder2.setCancelable(false);
dialogBuilder2.setView(dialogView2);
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();
}
AlertDialog alertDialog2 = dialogBuilder2.create();
alertDialog2.show();
private void handlerNoCardHandler(Message msg) {
iccDetectedThread.interrupt();
pd.dismiss();
break;
AlertDialog.Builder dialogBuilder1 = new AlertDialog.Builder(ICCActivity.this);
LayoutInflater inflater1 = (LayoutInflater) ICCActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView1 = inflater1.inflate(R.layout.confirm, null);
TextView textMessage1 = dialogView1.findViewById(R.id.text_message_confirm);
TextView textTitle1 = dialogView1.findViewById(R.id.text_title_confirm);
textTitle1.setText("Error");
textMessage1.setText("No card detected. Please insert card to read.");
dialogBuilder1.setPositiveButton("OK", (dialog, which) -> {
stopChecking = false;
insertCard();
});
dialogBuilder1.setCancelable(false);
dialogBuilder1.setView(dialogView1);
AlertDialog alertDialog1 = dialogBuilder1.create();
alertDialog1.show();
}
private void handlerInvalidCard(Message msg) {
iccDetectedThread.interrupt();
pd.dismiss();
AlertDialog.Builder dialogBuilder2 = new AlertDialog.Builder(ICCActivity.this);
LayoutInflater inflater2 = (LayoutInflater) ICCActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView2 = inflater2.inflate(R.layout.confirm, null);
TextView textMessage2 = dialogView2.findViewById(R.id.text_message_confirm);
TextView textTitle2 = dialogView2.findViewById(R.id.text_title_confirm);
textTitle2.setText("Error");
textMessage2.setText(msg.obj.toString());
dialogBuilder2.setPositiveButton("OK", (dialog, which) -> {
stopChecking = false;
insertCard();
});
dialogBuilder2.setCancelable(false);
dialogBuilder2.setView(dialogView2);
AlertDialog alertDialog2 = dialogBuilder2.create();
alertDialog2.show();
}
default:
break;
}
}
};
@SuppressLint("HandlerLeak")
private final Handler handlerCard = new Handler() {
public void handleMessage(Message msg) {
@ -180,9 +211,9 @@ public class ICCActivity extends AppCompatActivity {
Logger.logD(name + ":" + cardNo);
setResult(RESULT_OK, outgoingIntent);
finish();
//finish();
//reset();
reset();
break;
default:
break;
@ -363,9 +394,6 @@ public class ICCActivity extends AppCompatActivity {
public void run() {
super.run();
String nric = "";
String name = "";
String cardVer = "";
IccTester.getInstance(ICCActivity.this).light(true);
while (!Thread.interrupted()) {
@ -393,38 +421,57 @@ public class ICCActivity extends AppCompatActivity {
if (isoRes != null) {
NRICData nricData = new NRICData();
try {
nric = NRICApduUtils.getIDNum(getApplicationContext());
// NRIC
nricData.setNric(NRICApduUtils.getIDNum(getApplicationContext()));
// Name
String orgName = NRICApduUtils.getOriginalName(getApplicationContext());
String gmpcName = NRICApduUtils.getGMPCName(getApplicationContext());
String kptName = NRICApduUtils.getKPTName(getApplicationContext());
nricData.setOrgName(orgName);
nricData.setGmpcName(gmpcName);
nricData.setKptName(kptName);
String selectedName = orgName;
if (selectedName.length() < gmpcName.length()) {
selectedName = gmpcName;
}
if (selectedName.length() < kptName.length()) {
selectedName = kptName;
}
name = selectedName;
if (selectedName.length() < gmpcName.length()) { selectedName = gmpcName; }
if (selectedName.length() < kptName.length()) { selectedName = kptName; }
nricData.setFinalName(selectedName);
byte[] isoResC = IccTester.getInstance(getApplicationContext()).isoCommand((byte) 0, readCard);
Log.d("ZZZ8", getHexValue(isoResC));
nricData.setGender(NRICApduUtils.getGender(getApplicationContext()));
byte[] isoResC1 = IccTester.getInstance(getApplicationContext()).isoCommand((byte) 0, readCard1);
Log.d("ZZZ9", getHexValue(isoResC1));
//NRICApduUtils.getOldIDNum(getApplicationContext());
//NRICApduUtils.getBirthDate(getApplicationContext());
byte[] isoResC2 = IccTester.getInstance(getApplicationContext()).isoCommand((byte) 0, readCard2);
Log.d("ZZZ10", getHexValue(isoResC2));
nricData.setBirthPlace(NRICApduUtils.getBirthPlace(getApplicationContext()));
byte[] cardBytes = Arrays.copyOfRange(isoResC2, 0, isoResC2.length - 2);
Log.d("ZZZ11", getHexValue(cardBytes));
Log.d("ZZZ11", new String(cardBytes));
//NRICApduUtils.getDateIssued(getApplicationContext());
cardVer = new String(cardBytes);
nricData.setCitizenship(NRICApduUtils.getCitizenship(getApplicationContext()));
nricData.setRace(NRICApduUtils.getRace(getApplicationContext()));
nricData.setReligion(NRICApduUtils.getReligion(getApplicationContext()));
nricData.setEastMalaysian(NRICApduUtils.getEastMalaysian(getApplicationContext()));
nric += getHexValue(cardBytes);
/*
NRICApduUtils.getRJ(getApplicationContext());
NRICApduUtils.getKT(getApplicationContext());
NRICApduUtils.getOtherID(getApplicationContext());
NRICApduUtils.getCategory(getApplicationContext());
NRICApduUtils.getCardVersion(getApplicationContext());
NRICApduUtils.getGreenCardExpiry(getApplicationContext());
NRICApduUtils.getGreenCardNationality(getApplicationContext());
*/
// Photo
nricData.setPhoto(NRICApduUtils.getPhoto(getApplicationContext()));
// Address
nricData.setAddress1(NRICApduUtils.getAddress1(getApplicationContext()));
nricData.setAddress2(NRICApduUtils.getAddress2(getApplicationContext()));
nricData.setAddress3(NRICApduUtils.getAddress3(getApplicationContext()));
//NRICApduUtils.getPostcode(getApplicationContext());
nricData.setCity(NRICApduUtils.getCity(getApplicationContext()));
nricData.setState(NRICApduUtils.getState(getApplicationContext()));
} catch (Exception e) {
ICCActivity.appendLog(e);
@ -433,14 +480,9 @@ public class ICCActivity extends AppCompatActivity {
IccTester.getInstance(getApplicationContext()).close((byte) 0);
IccTester.getInstance(getApplicationContext()).light(false);
ArrayList<String> info = new ArrayList<>();
info.add(nric);
info.add(name);
info.add(cardVer);
Message message = Message.obtain();
message.what = 0;
message.obj = info;
message.obj = nricData;
handler.sendMessage(message);
} else {
Message message = Message.obtain();
@ -450,7 +492,6 @@ public class ICCActivity extends AppCompatActivity {
}
} else {
//resString = getResources().getString(R.string.icc_detect_nocard);
Message message = Message.obtain();
message.what = 1;
message.obj = "No card.";

22
app/src/main/java/com/cst/im30/model/NRICData.java

@ -0,0 +1,22 @@
package com.cst.im30.model;
import java.io.Serializable;
import lombok.Data;
@Data
public class NRICData implements Serializable {
String nric;
String orgName;
String gmpcName;
String kptName;
byte[] photo;
String finalName; // Longest String of orgName / gmpcName / kptName
String gender, birthPlace, citizenship, race, religion, eastMalaysian;
String address1, address2, address3, city, state;
}

693
app/src/main/java/com/cst/im30/utility/NRICApduUtils.java

@ -1,7 +1,10 @@
package com.cst.im30.utility;
import android.content.Context;
import android.util.Log;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
@SuppressWarnings({"unused"})
@ -15,10 +18,20 @@ public class NRICApduUtils {
return IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectJpn);
}
// JPN - 1 - 1
public static String getOriginalName(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x96, (byte) 0x00};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x96, (byte) 0x00};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x96};
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x96, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x03, (byte) 0x00,
(byte) 0x96, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x96
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
@ -34,9 +47,17 @@ public class NRICApduUtils {
}
public static String getGMPCName(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x50, (byte) 0x00};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x99, (byte) 0x00, (byte) 0x50, (byte) 0x00};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x50};
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x50, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x99, (byte) 0x00,
(byte) 0x50, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x50
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
@ -52,9 +73,17 @@ public class NRICApduUtils {
}
public static String getKPTName(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x28, (byte) 0x00};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0xE9, (byte) 0x00, (byte) 0x28, (byte) 0x00};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x28};
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x28, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0xE9, (byte) 0x00,
(byte) 0x28, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x28
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
@ -70,9 +99,17 @@ public class NRICApduUtils {
}
public static String getIDNum(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x0D, (byte) 0x00};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x11, (byte) 0x01, (byte) 0x0D, (byte) 0x00};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x0D};
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x0D, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x11, (byte) 0x01,
(byte) 0x0D, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x0D
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
@ -86,4 +123,636 @@ public class NRICApduUtils {
return str;
}
public static String getGender(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x01, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x1E, (byte) 0x01,
(byte) 0x01, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x01
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 2);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_Gender:" + str);
return str;
}
public static String getOldIDNum(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x08, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x1F, (byte) 0x01,
(byte) 0x08, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x08
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_OldIDNum:" + str);
return str;
}
//TODO date object, dunno how to convert
public static String getBirthDate(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x04, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x27, (byte) 0x01,
(byte) 0x04, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x04
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 0);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_BirthDate:" + str);
return str;
}
public static String getBirthPlace(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x19, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x2B, (byte) 0x01,
(byte) 0x19, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x19
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_BirthPlace:" + str);
return str;
}
//TODO date object, dunno how to convert
public static String getDateIssued(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x04, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x44, (byte) 0x01,
(byte) 0x04, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x04
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_DateIssued:" + str);
return str;
}
public static String getCitizenship(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x12, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x48, (byte) 0x01,
(byte) 0x12, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x12
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_Citizenship:" + str);
return str;
}
public static String getRace(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x19, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x5A, (byte) 0x01,
(byte) 0x19, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x19
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_Race:" + str);
return str;
}
public static String getReligion(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x0B, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x73, (byte) 0x01,
(byte) 0x0B, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x0B
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_Religion:" + str);
return str;
}
public static String getEastMalaysian(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x01, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x7E, (byte) 0x01,
(byte) 0x01, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x01
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 2);
String str = new String(trimmedBytes);
Logger.logD("JPN_EastMalaysian:" + str);
return str;
}
// ?
public static String getRJ(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x02, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x7F, (byte) 0x01,
(byte) 0x02, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x02
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_RJ:" + str);
return str;
}
// ?
public static String getKT(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x02, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x81, (byte) 0x01,
(byte) 0x02, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x02
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_KT:" + str);
return str;
}
// ?
public static String getOtherID(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x0B, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x83, (byte) 0x01,
(byte) 0x0B, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x0B
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 0);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_OtherID:" + str);
return str;
}
// ?
public static String getCategory(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x01, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x8E, (byte) 0x01,
(byte) 0x01, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x01
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 0);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_Category:" + str);
return str;
}
// ?
public static String getCardVersion(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x01, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x8F, (byte) 0x01,
(byte) 0x01, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x01
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 0);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_CardVersion:" + str);
return str;
}
//TODO date object, dunno how to convert
public static String getGreenCardExpiry(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x04, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x90, (byte) 0x01,
(byte) 0x04, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x04
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_GreenCardExpiry:" + str);
return str;
}
// ?
public static String getGreenCardNationality(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x14, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x94, (byte) 0x01,
(byte) 0x14, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x14
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_GreenCardNationality:" + str);
return str;
}
// JPN - 1 - 2
public static byte[] getPhoto(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte)0xC8, (byte)0x32, (byte)0x00, (byte)0x00,(byte)0x05, (byte)0x08, (byte)0x00, (byte)0x00,
(byte)0xA0, (byte)0x0F // Length - 4000 Little-Endian
};
byte[] selectInfoByte = new byte[]{(byte)0xCC, (byte)0x00, (byte)0x00, (byte)0x00,(byte)0x08,
(byte)0x02, (byte)0x00, (byte)0x01, (byte)0x00, // JPN-1-2
(byte)0x03, (byte)0x00, // Offset - Little-Endian
(byte)0xA0, (byte)0x0F // Length - 4000 Little-Endian
};
byte[] readInfoByte = new byte[]{(byte)0xCC, (byte)0x06, (byte)0x00, (byte)0x00,
(byte)0xFF // Read Length - 255
};
byte[] readInfoByteFinal = new byte[]{(byte)0xCC, (byte)0x06, (byte)0x00, (byte)0x00,
(byte)0xAF // Read Length 175
};
int fullReads = (int) Math.floor((double)4000 / (double)255);
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
for (int i = 0; i < fullReads; i++) {
byte[] tmp = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] finalTmp = Arrays.copyOfRange(tmp, 0 , tmp.length -2);
try {
outputStream.write( finalTmp );
} catch (IOException e) {
Logger.logE(Log.getStackTraceString(e));
e.printStackTrace();
return null;
}
}
byte[] tmp = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByteFinal);
byte[] finalTmp = Arrays.copyOfRange(tmp, 0 , tmp.length -2);
try {
outputStream.write( finalTmp );
} catch (IOException e) {
Logger.logE(Log.getStackTraceString(e));
e.printStackTrace();
return null;
}
return outputStream.toByteArray();
}
// JPN - 1 - 4
public static String getAddress1(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x1E, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x03, (byte) 0x00,
(byte) 0x1E, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x1E
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_Address1:" + str);
return str;
}
public static String getAddress2(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x1E, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x21, (byte) 0x00,
(byte) 0x1E, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x1E
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_Address2:" + str);
return str;
}
public static String getAddress3(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x1E, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x3F, (byte) 0x00,
(byte) 0x1E, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x1E
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_Address3:" + str);
return str;
}
//TODO postcode object, dunno how to convert
public static String getPostcode(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x03, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x5D, (byte) 0x00,
(byte) 0x03, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x03
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_Postcode:" + str);
return str;
}
public static String getCity(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x19, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x60, (byte) 0x00,
(byte) 0x19, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x19
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_City:" + str);
return str;
}
public static String getState(Context applicationContext) {
byte[] setLengthByte = new byte[]{(byte) 0xC8, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x08, (byte) 0x00, (byte) 0x00,
(byte) 0x1E, (byte) 0x00
};
byte[] selectInfoByte = new byte[]{(byte) 0xCC, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08,
(byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x00,
(byte) 0x79, (byte) 0x00,
(byte) 0x1E, (byte) 0x00
};
byte[] readInfoByte = new byte[]{(byte) 0xCC, (byte) 0x06, (byte) 0x00, (byte) 0x00,
(byte) 0x1E
};
byte[] setLengthByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, setLengthByte);
byte[] selectInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, selectInfoByte);
byte[] readInfoByteResponse = IccTester.getInstance(applicationContext).isoCommand((byte) 0, readInfoByte);
byte[] trimmedBytes = Arrays.copyOfRange(readInfoByteResponse, 0, readInfoByteResponse.length - 3);
String str = new String(trimmedBytes).trim();
Logger.logD("JPN_State:" + str);
return str;
}
}

46
app/src/main/res/layout/confirm_read.xml

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/text_title_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2E7D32"
android:padding="16dp"
android:textAlignment="center"
android:textColor="#f7f7f7"
android:textStyle="bold" />
<ImageView
android:id="@+id/image_view"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:contentDescription="IC Photo"
android:scaleType="fitCenter"
android:src="@drawable/echo_payment_online"
android:visibility="gone"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/text_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textAlignment="center"
android:textColor="@android:color/black"
android:visibility="gone" />
<TextView
android:id="@+id/text_message_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:textAlignment="center" />
</LinearLayout>

17
app/src/test/java/com/cst/im30/ExampleUnitTest.java

@ -1,17 +0,0 @@
package com.cst.im30;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

2
settings.gradle

@ -1,2 +1,2 @@
rootProject.name = "kiosk-im30"
rootProject.name = "pax_kiosk_im30"
include ':app'

Loading…
Cancel
Save