Problems: I got status 3 was error NO_SUCH_ELEMENT when using euicc manager sending apdu.
What I did: I sorted an euicc chip (ST33G1M2)and pluggin into my phone, and trying to port the euicc manager (com.google.android.euicc, premission granted) to my phone. Now debugging and this error occurs (NO_SUCH_ELEMENT)
Needed: I cannot find how to call lower level or hardware. could anyone helps about hal/hardware of Android system? or did you have meet this error.
I traceback them at aosp codes (the file provided below),but I didn’t see anything about hardware. Does it async to another proccess?
PhoneInterfaceManager.java:
case CMD_OPEN_CHANNEL:
request = (MainThreadRequest) msg.obj;
uiccPort = getUiccPortFromRequest(request);
IccLogicalChannelRequest openChannelRequest =
(IccLogicalChannelRequest) request.argument;
if (uiccPort == null) {
loge("iccOpenLogicalChannel: No UICC");
request.result = new IccOpenLogicalChannelResponse(-1,
IccOpenLogicalChannelResponse.STATUS_MISSING_RESOURCE, null);
notifyRequester(request);
} else {
onCompleted = obtainMessage(EVENT_OPEN_CHANNEL_DONE, request);
uiccPort.iccOpenLogicalChannel(openChannelRequest.aid,
openChannelRequest.p2, onCompleted);
}
break;
case EVENT_OPEN_CHANNEL_DONE:
ar = (AsyncResult) msg.obj;
request = (MainThreadRequest) ar.userObj;
IccOpenLogicalChannelResponse openChannelResp;
if (ar.exception == null && ar.result != null) {
int[] result = (int[]) ar.result;
int channelId = result[0];
byte[] selectResponse = null;
if (result.length > 1) {
selectResponse = new byte[result.length - 1];
for (int i = 1; i < result.length; ++i) {
selectResponse[i - 1] = (byte) result[i];
}
}
openChannelResp = new IccOpenLogicalChannelResponse(channelId,
IccOpenLogicalChannelResponse.STATUS_NO_ERROR, selectResponse);
uiccPort = getUiccPortFromRequest(request);
if (uiccPort == null) {
loge("EVENT_OPEN_CHANNEL_DONE: UiccPort is null");
} else {
IccLogicalChannelRequest channelRequest =
(IccLogicalChannelRequest) request.argument;
channelRequest.channel = channelId;
uiccPort.onLogicalChannelOpened(channelRequest);
}
} else {
if (ar.result == null) {
loge("iccOpenLogicalChannel: Empty response");
}
if (ar.exception != null) {
loge("iccOpenLogicalChannel: Exception: " + ar.exception);
}
int errorCode = IccOpenLogicalChannelResponse.STATUS_UNKNOWN_ERROR;
if (ar.exception instanceof CommandException) {
CommandException.Error error =
((CommandException) (ar.exception)).getCommandError();
if (error == CommandException.Error.MISSING_RESOURCE) {
errorCode = IccOpenLogicalChannelResponse.STATUS_MISSING_RESOURCE;
} else if (error == CommandException.Error.NO_SUCH_ELEMENT) {
errorCode = IccOpenLogicalChannelResponse.STATUS_NO_SUCH_ELEMENT;
}
}
openChannelResp = new IccOpenLogicalChannelResponse(
IccOpenLogicalChannelResponse.INVALID_CHANNEL, errorCode, null);
}
request.result = openChannelResp;
notifyRequester(request);
break;
logs below:
2023-10-14 13:22:14.534 3860-3860 EuiccCardController com.android.phone E getEuiccChallenge callback onException:
com.android.internal.telephony.uicc.euicc.EuiccCardException: Cannot send APDU.
at com.android.internal.telephony.uicc.euicc.EuiccPort.lambda$sendApdu$50(EuiccPort.java:1159)
at com.android.internal.telephony.uicc.euicc.EuiccPort.$r8$lambda$8x9Mw_LfktrBXDaDFYF0Xl8vpps(Unknown Source:0)
at com.android.internal.telephony.uicc.euicc.EuiccPort$$ExternalSyntheticLambda52.handleException(Unknown Source:2)
at com.android.internal.telephony.uicc.euicc.EuiccPort$1.onException(EuiccPort.java:1224)
at com.android.internal.telephony.uicc.euicc.apdu.ApduSender$1.onResult(ApduSender.java:138)
at com.android.internal.telephony.uicc.euicc.apdu.ApduSender$1.onResult(ApduSender.java:127)
at com.android.internal.telephony.uicc.euicc.async.AsyncMessageInvocation.handleMessage(AsyncMessageInvocation.java:57)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loopOnce(Looper.java:238)
at android.os.Looper.loop(Looper.java:357)
at android.app.ActivityThread.main(ActivityThread.java:8088)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957)
Caused by: com.android.internal.telephony.uicc.euicc.apdu.ApduException: Failed to open logical channel opened for AID: A0000005591010FFFFFFFF8900000100, with status: 3 (apduStatus=0)
at com.android.internal.telephony.uicc.euicc.apdu.ApduSender$1.onResult(ApduSender.java:138)
at com.android.internal.telephony.uicc.euicc.apdu.ApduSender$1.onResult(ApduSender.java:127)
at com.android.internal.telephony.uicc.euicc.async.AsyncMessageInvocation.handleMessage(AsyncMessageInvocation.java:57)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loopOnce(Looper.java:238)
at android.os.Looper.loop(Looper.java:357)
at android.app.ActivityThread.main(ActivityThread.java:8088)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957)
2023-10-14 13:22:18.904 3860-3860 EuiccCardController com.android.phone E getEuiccChallenge callback onException:
com.android.internal.telephony.uicc.euicc.EuiccCardException: Cannot send APDU.
at com.android.internal.telephony.uicc.euicc.EuiccPort.lambda$sendApdu$50(EuiccPort.java:1159)
at com.android.internal.telephony.uicc.euicc.EuiccPort.$r8$lambda$8x9Mw_LfktrBXDaDFYF0Xl8vpps(Unknown Source:0)
at com.android.internal.telephony.uicc.euicc.EuiccPort$$ExternalSyntheticLambda52.handleException(Unknown Source:2)
at com.android.internal.telephony.uicc.euicc.EuiccPort$1.onException(EuiccPort.java:1224)
at com.android.internal.telephony.uicc.euicc.apdu.ApduSender$1.onResult(ApduSender.java:138)
at com.android.internal.telephony.uicc.euicc.apdu.ApduSender$1.onResult(ApduSender.java:127)
at com.android.internal.telephony.uicc.euicc.async.AsyncMessageInvocation.handleMessage(AsyncMessageInvocation.java:57)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loopOnce(Looper.java:238)
at android.os.Looper.loop(Looper.java:357)
at android.app.ActivityThread.main(ActivityThread.java:8088)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957)
Caused by: com.android.internal.telephony.uicc.euicc.apdu.ApduException: Failed to open logical channel opened for AID: A0000005591010FFFFFFFF8900000100, with status: 3 (apduStatus=0)
at com.android.internal.telephony.uicc.euicc.apdu.ApduSender$1.onResult(ApduSender.java:138)
at com.android.internal.telephony.uicc.euicc.apdu.ApduSender$1.onResult(ApduSender.java:127)
at com.android.internal.telephony.uicc.euicc.async.AsyncMessageInvocation.handleMessage(AsyncMessageInvocation.java:57)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loopOnce(Looper.java:238)
at android.os.Looper.loop(Looper.java:357)
at android.app.ActivityThread.main(ActivityThread.java:8088)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957)