Loading telephony/java/com/android/internal/telephony/cat/BerTlv.java +15 −5 Original line number Diff line number Diff line Loading @@ -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)) { Loading @@ -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, Loading telephony/java/com/android/internal/telephony/cat/CommandDetails.java +8 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading telephony/java/com/android/internal/telephony/cat/CommandParams.java +5 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,11 @@ class CommandParams { } boolean setIcon(Bitmap icon) { return true; } @Override public String toString() { return cmdDet.toString(); } } class DisplayTextParams extends CommandParams { Loading telephony/java/com/android/internal/telephony/cat/CommandParamsFactory.java +3 −1 Original line number Diff line number Diff line Loading @@ -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); } } } Loading Loading @@ -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; Loading telephony/java/com/android/internal/telephony/cat/ComprehensionTlv.java +30 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.internal.telephony.cat; import android.util.Log; import java.util.ArrayList; import java.util.List; Loading Loading @@ -112,10 +114,10 @@ class ComprehensionTlv { */ public static ComprehensionTlv decode(byte[] data, int startIndex) throws ResultException { try { int curIndex = startIndex; int endIndex = data.length; try { /* tag */ int tag; boolean cr; // Comprehension required flag Loading @@ -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 Loading @@ -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) Loading @@ -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) Loading @@ -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); } } } Loading
telephony/java/com/android/internal/telephony/cat/BerTlv.java +15 −5 Original line number Diff line number Diff line Loading @@ -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)) { Loading @@ -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, Loading
telephony/java/com/android/internal/telephony/cat/CommandDetails.java +8 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading
telephony/java/com/android/internal/telephony/cat/CommandParams.java +5 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,11 @@ class CommandParams { } boolean setIcon(Bitmap icon) { return true; } @Override public String toString() { return cmdDet.toString(); } } class DisplayTextParams extends CommandParams { Loading
telephony/java/com/android/internal/telephony/cat/CommandParamsFactory.java +3 −1 Original line number Diff line number Diff line Loading @@ -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); } } } Loading Loading @@ -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; Loading
telephony/java/com/android/internal/telephony/cat/ComprehensionTlv.java +30 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.internal.telephony.cat; import android.util.Log; import java.util.ArrayList; import java.util.List; Loading Loading @@ -112,10 +114,10 @@ class ComprehensionTlv { */ public static ComprehensionTlv decode(byte[] data, int startIndex) throws ResultException { try { int curIndex = startIndex; int endIndex = data.length; try { /* tag */ int tag; boolean cr; // Comprehension required flag Loading @@ -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 Loading @@ -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) Loading @@ -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) Loading @@ -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); } } }