Additional logging information for Card Application Toolkit/SIM Toolkit
Add an optional explanation field and toString to ResultException Add toString to CommandDetails. Add add a few more log statements on error paths. Bug: 5852715 Change-Id: I8594178002a67798aa3fb38ce1ee15c1a41f1854
This commit is contained in:
@ -81,12 +81,18 @@ class BerTlv {
|
||||
temp = data[curIndex++] & 0xff;
|
||||
if (temp < 0x80) {
|
||||
throw new ResultException(
|
||||
ResultCode.CMD_DATA_NOT_UNDERSTOOD);
|
||||
ResultCode.CMD_DATA_NOT_UNDERSTOOD,
|
||||
"length < 0x80 length=" + Integer.toHexString(length) +
|
||||
" curIndex=" + curIndex + " endIndex=" + endIndex);
|
||||
|
||||
}
|
||||
length = temp;
|
||||
} else {
|
||||
throw new ResultException(
|
||||
ResultCode.CMD_DATA_NOT_UNDERSTOOD);
|
||||
ResultCode.CMD_DATA_NOT_UNDERSTOOD,
|
||||
"Expected first byte to be length or a length tag and < 0x81" +
|
||||
" byte= " + Integer.toHexString(temp) + " curIndex=" + curIndex +
|
||||
" endIndex=" + endIndex);
|
||||
}
|
||||
} else {
|
||||
if (ComprehensionTlvTag.COMMAND_DETAILS.value() == (tag & ~0x80)) {
|
||||
@ -95,14 +101,18 @@ class BerTlv {
|
||||
}
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
throw new ResultException(ResultCode.REQUIRED_VALUES_MISSING);
|
||||
throw new ResultException(ResultCode.REQUIRED_VALUES_MISSING,
|
||||
"IndexOutOfBoundsException " +
|
||||
" curIndex=" + curIndex + " endIndex=" + endIndex);
|
||||
} catch (ResultException e) {
|
||||
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
|
||||
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD, e.explanation());
|
||||
}
|
||||
|
||||
/* COMPREHENSION-TLVs */
|
||||
if (endIndex - curIndex < length) {
|
||||
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
|
||||
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD,
|
||||
"Command had extra data endIndex=" + endIndex + " curIndex=" + curIndex +
|
||||
" length=" + length);
|
||||
}
|
||||
|
||||
List<ComprehensionTlv> ctlvs = ComprehensionTlv.decodeMany(data,
|
||||
|
@ -74,6 +74,14 @@ class CommandDetails extends ValueObject implements Parcelable {
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CmdDetails: compRequired=" + compRequired +
|
||||
" commandNumber=" + commandNumber +
|
||||
" typeOfCommand=" + typeOfCommand +
|
||||
" commandQualifier=" + commandQualifier;
|
||||
}
|
||||
}
|
||||
|
||||
class DeviceIdentities extends ValueObject {
|
||||
|
@ -34,6 +34,11 @@ class CommandParams {
|
||||
}
|
||||
|
||||
boolean setIcon(Bitmap icon) { return true; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return cmdDet.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class DisplayTextParams extends CommandParams {
|
||||
|
@ -83,7 +83,8 @@ class CommandParamsFactory extends Handler {
|
||||
try {
|
||||
cmdDet = ValueParser.retrieveCommandDetails(ctlvCmdDet);
|
||||
} catch (ResultException e) {
|
||||
CatLog.d(this, "Failed to procees command details");
|
||||
CatLog.d(this,
|
||||
"processCommandDetails: Failed to procees command details e=" + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,6 +179,7 @@ class CommandParamsFactory extends Handler {
|
||||
return;
|
||||
}
|
||||
} catch (ResultException e) {
|
||||
CatLog.d(this, "make: caught ResultException e=" + e);
|
||||
mCmdParams = new CommandParams(cmdDet);
|
||||
sendCmdParams(e.result());
|
||||
return;
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.internal.telephony.cat;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -112,10 +114,10 @@ class ComprehensionTlv {
|
||||
*/
|
||||
public static ComprehensionTlv decode(byte[] data, int startIndex)
|
||||
throws ResultException {
|
||||
try {
|
||||
int curIndex = startIndex;
|
||||
int endIndex = data.length;
|
||||
int curIndex = startIndex;
|
||||
int endIndex = data.length;
|
||||
|
||||
try {
|
||||
/* tag */
|
||||
int tag;
|
||||
boolean cr; // Comprehension required flag
|
||||
@ -124,9 +126,11 @@ class ComprehensionTlv {
|
||||
case 0:
|
||||
case 0xff:
|
||||
case 0x80:
|
||||
// for error handling
|
||||
// these one make exception while decoding the abnormal command.
|
||||
// (in case of Ghana MTN simcard , JDI simcard)
|
||||
Log.d("CAT ", "decode: unexpected first tag byte=" + Integer.toHexString(temp) +
|
||||
", startIndex=" + startIndex + " curIndex=" + curIndex +
|
||||
" endIndex=" + endIndex);
|
||||
// Return null which will stop decoding, this has occurred
|
||||
// with Ghana MTN simcard and JDI simcard.
|
||||
return null;
|
||||
|
||||
case 0x7f: // tag is in three-byte format
|
||||
@ -153,7 +157,10 @@ class ComprehensionTlv {
|
||||
length = data[curIndex++] & 0xff;
|
||||
if (length < 0x80) {
|
||||
throw new ResultException(
|
||||
ResultCode.CMD_DATA_NOT_UNDERSTOOD);
|
||||
ResultCode.CMD_DATA_NOT_UNDERSTOOD,
|
||||
"length < 0x80 length=" + Integer.toHexString(length) +
|
||||
" startIndex=" + startIndex + " curIndex=" + curIndex +
|
||||
" endIndex=" + endIndex);
|
||||
}
|
||||
} else if (temp == 0x82) {
|
||||
length = ((data[curIndex] & 0xff) << 8)
|
||||
@ -161,7 +168,10 @@ class ComprehensionTlv {
|
||||
curIndex += 2;
|
||||
if (length < 0x100) {
|
||||
throw new ResultException(
|
||||
ResultCode.CMD_DATA_NOT_UNDERSTOOD);
|
||||
ResultCode.CMD_DATA_NOT_UNDERSTOOD,
|
||||
"two byte length < 0x100 length=" + Integer.toHexString(length) +
|
||||
" startIndex=" + startIndex + " curIndex=" + curIndex +
|
||||
" endIndex=" + endIndex);
|
||||
}
|
||||
} else if (temp == 0x83) {
|
||||
length = ((data[curIndex] & 0xff) << 16)
|
||||
@ -170,16 +180,25 @@ class ComprehensionTlv {
|
||||
curIndex += 3;
|
||||
if (length < 0x10000) {
|
||||
throw new ResultException(
|
||||
ResultCode.CMD_DATA_NOT_UNDERSTOOD);
|
||||
ResultCode.CMD_DATA_NOT_UNDERSTOOD,
|
||||
"three byte length < 0x10000 length=0x" + Integer.toHexString(length) +
|
||||
" startIndex=" + startIndex + " curIndex=" + curIndex +
|
||||
" endIndex=" + endIndex);
|
||||
}
|
||||
} else {
|
||||
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
|
||||
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD,
|
||||
"Bad length modifer=" + temp +
|
||||
" startIndex=" + startIndex + " curIndex=" + curIndex +
|
||||
" endIndex=" + endIndex);
|
||||
|
||||
}
|
||||
|
||||
return new ComprehensionTlv(tag, cr, length, data, curIndex);
|
||||
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
|
||||
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD,
|
||||
"IndexOutOfBoundsException" + " startIndex=" + startIndex +
|
||||
" curIndex=" + curIndex + " endIndex=" + endIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ package com.android.internal.telephony.cat;
|
||||
public class ResultException extends CatException {
|
||||
private ResultCode mResult;
|
||||
private int mAdditionalInfo;
|
||||
private String mExplanation;
|
||||
|
||||
public ResultException(ResultCode result) {
|
||||
super();
|
||||
@ -48,20 +49,30 @@ public class ResultException extends CatException {
|
||||
|
||||
mResult = result;
|
||||
mAdditionalInfo = -1;
|
||||
mExplanation = "";
|
||||
}
|
||||
|
||||
public ResultException(ResultCode result, String explanation) {
|
||||
this(result);
|
||||
mExplanation = explanation;
|
||||
}
|
||||
|
||||
public ResultException(ResultCode result, int additionalInfo) {
|
||||
super();
|
||||
this(result);
|
||||
|
||||
if (additionalInfo < 0) {
|
||||
throw new AssertionError(
|
||||
"Additional info must be greater than zero!");
|
||||
}
|
||||
|
||||
mResult = result;
|
||||
mAdditionalInfo = additionalInfo;
|
||||
}
|
||||
|
||||
public ResultException(ResultCode result, int additionalInfo, String explanation) {
|
||||
this(result, additionalInfo);
|
||||
mExplanation = explanation;
|
||||
}
|
||||
|
||||
public ResultCode result() {
|
||||
return mResult;
|
||||
}
|
||||
@ -73,4 +84,14 @@ public class ResultException extends CatException {
|
||||
public int additionalInfo() {
|
||||
return mAdditionalInfo;
|
||||
}
|
||||
|
||||
public String explanation() {
|
||||
return mExplanation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "result=" + mResult + " additionalInfo=" + mAdditionalInfo +
|
||||
" explantion=" + mExplanation;
|
||||
}
|
||||
}
|
||||
|
@ -162,6 +162,7 @@ class RilMessageDecoder extends StateMachine {
|
||||
decodingStarted = true;
|
||||
} catch (ResultException e) {
|
||||
// send to Service for proper RIL communication.
|
||||
CatLog.d(this, "decodeMessageParams: caught ResultException e=" + e);
|
||||
mCurrentRilMessage.mResCode = e.result();
|
||||
sendCmdForExecution(mCurrentRilMessage);
|
||||
decodingStarted = false;
|
||||
|
Reference in New Issue
Block a user