Loading telephony/java/com/android/internal/telephony/IccUtils.java +7 −4 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public class IccUtils { * exactly as received" */ public static int bcdByteToInt(byte b) { gsmBcdByteToInt(byte b) { int ret = 0; // treat out-of-range BCD values as 0 Loading @@ -89,11 +89,14 @@ public class IccUtils { return ret; } /** Decodes BCD byte like {@link bcdByteToInt}, but the most significant BCD * digit is expected in the most significant nibble. /** * Decodes a CDMA style BCD byte like {@link gsmBcdByteToInt}, but * opposite nibble format. The least significant BCD digit * is in the least significant nibble and the most significant * is in the most significant nibble. */ public static int beBcdByteToInt(byte b) { cdmaBcdByteToInt(byte b) { int ret = 0; // treat out-of-range BCD values as 0 Loading telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java +7 −7 Original line number Diff line number Diff line Loading @@ -233,22 +233,22 @@ public final class BearerData { public static TimeStamp fromByteArray(byte[] data) { TimeStamp ts = new TimeStamp(); // C.S0015-B v2.0, 4.5.4: range is 1996-2095 int year = IccUtils.beBcdByteToInt(data[0]); int year = IccUtils.cdmaBcdByteToInt(data[0]); if (year > 99 || year < 0) return null; ts.year = year >= 96 ? year + 1900 : year + 2000; int month = IccUtils.beBcdByteToInt(data[1]); int month = IccUtils.cdmaBcdByteToInt(data[1]); if (month < 1 || month > 12) return null; ts.month = month - 1; int day = IccUtils.beBcdByteToInt(data[2]); int day = IccUtils.cdmaBcdByteToInt(data[2]); if (day < 1 || day > 31) return null; ts.monthDay = day; int hour = IccUtils.beBcdByteToInt(data[3]); int hour = IccUtils.cdmaBcdByteToInt(data[3]); if (hour < 0 || hour > 23) return null; ts.hour = hour; int minute = IccUtils.beBcdByteToInt(data[4]); int minute = IccUtils.cdmaBcdByteToInt(data[4]); if (minute < 0 || minute > 59) return null; ts.minute = minute; int second = IccUtils.beBcdByteToInt(data[5]); int second = IccUtils.cdmaBcdByteToInt(data[5]); if (second < 0 || second > 59) return null; ts.second = second; return ts; Loading Loading @@ -1153,7 +1153,7 @@ public final class BearerData { if (paramBits >= EXPECTED_PARAM_SIZE) { paramBits -= EXPECTED_PARAM_SIZE; decodeSuccess = true; bData.numberOfMessages = IccUtils.beBcdByteToInt((byte)inStream.read(8)); bData.numberOfMessages = IccUtils.cdmaBcdByteToInt((byte)inStream.read(8)); } if ((! decodeSuccess) || (paramBits > 0)) { Log.d(LOG_TAG, "NUMBER_OF_MESSAGES decode " + Loading telephony/java/com/android/internal/telephony/gsm/SmsMessage.java +8 −10 Original line number Diff line number Diff line Loading @@ -519,12 +519,12 @@ public class SmsMessage extends SmsMessageBase{ long getSCTimestampMillis() { // TP-Service-Centre-Time-Stamp int year = IccUtils.bcdByteToInt(pdu[cur++]); int month = IccUtils.bcdByteToInt(pdu[cur++]); int day = IccUtils.bcdByteToInt(pdu[cur++]); int hour = IccUtils.bcdByteToInt(pdu[cur++]); int minute = IccUtils.bcdByteToInt(pdu[cur++]); int second = IccUtils.bcdByteToInt(pdu[cur++]); int year = IccUtils.gsmBcdByteToInt(pdu[cur++]); int month = IccUtils.gsmBcdByteToInt(pdu[cur++]); int day = IccUtils.gsmBcdByteToInt(pdu[cur++]); int hour = IccUtils.gsmBcdByteToInt(pdu[cur++]); int minute = IccUtils.gsmBcdByteToInt(pdu[cur++]); int second = IccUtils.gsmBcdByteToInt(pdu[cur++]); // For the timezone, the most significant bit of the // least signficant nibble is the sign byte Loading @@ -534,11 +534,9 @@ public class SmsMessage extends SmsMessageBase{ byte tzByte = pdu[cur++]; // Mask out sign bit. int timezoneOffset = IccUtils .bcdByteToInt((byte) (tzByte & (~0x08))); int timezoneOffset = IccUtils.gsmBcdByteToInt((byte) (tzByte & (~0x08))); timezoneOffset = ((tzByte & 0x08) == 0) ? timezoneOffset : -timezoneOffset; timezoneOffset = ((tzByte & 0x08) == 0) ? timezoneOffset : -timezoneOffset; Time time = new Time(Time.TIMEZONE_UTC); Loading tests/CoreTests/com/android/internal/telephony/SimUtilsTest.java +13 −5 Original line number Diff line number Diff line Loading @@ -44,13 +44,22 @@ public class SimUtilsTest extends TestCase { assertEquals("890", IccUtils.bcdToString(data, 0, data.length)); /* * bcdByteToInt() * gsmBcdByteToInt() */ assertEquals(98, IccUtils.bcdByteToInt((byte) 0x89)); assertEquals(98, IccUtils.gsmBcdByteToInt((byte) 0x89)); // Out of range is treated as 0 assertEquals(8, IccUtils.bcdByteToInt((byte) 0x8c)); assertEquals(8, IccUtils.gsmBcdByteToInt((byte) 0x8c)); /* * cdmaBcdByteToInt() */ assertEquals(89, IccUtils.cdmaBcdByteToInt((byte) 0x89)); // Out of range is treated as 0 assertEquals(80, IccUtils.gsmBcdByteToInt((byte) 0x8c)); /* * adnStringFieldToString() Loading @@ -76,4 +85,3 @@ public class SimUtilsTest extends TestCase { } } Loading
telephony/java/com/android/internal/telephony/IccUtils.java +7 −4 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public class IccUtils { * exactly as received" */ public static int bcdByteToInt(byte b) { gsmBcdByteToInt(byte b) { int ret = 0; // treat out-of-range BCD values as 0 Loading @@ -89,11 +89,14 @@ public class IccUtils { return ret; } /** Decodes BCD byte like {@link bcdByteToInt}, but the most significant BCD * digit is expected in the most significant nibble. /** * Decodes a CDMA style BCD byte like {@link gsmBcdByteToInt}, but * opposite nibble format. The least significant BCD digit * is in the least significant nibble and the most significant * is in the most significant nibble. */ public static int beBcdByteToInt(byte b) { cdmaBcdByteToInt(byte b) { int ret = 0; // treat out-of-range BCD values as 0 Loading
telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java +7 −7 Original line number Diff line number Diff line Loading @@ -233,22 +233,22 @@ public final class BearerData { public static TimeStamp fromByteArray(byte[] data) { TimeStamp ts = new TimeStamp(); // C.S0015-B v2.0, 4.5.4: range is 1996-2095 int year = IccUtils.beBcdByteToInt(data[0]); int year = IccUtils.cdmaBcdByteToInt(data[0]); if (year > 99 || year < 0) return null; ts.year = year >= 96 ? year + 1900 : year + 2000; int month = IccUtils.beBcdByteToInt(data[1]); int month = IccUtils.cdmaBcdByteToInt(data[1]); if (month < 1 || month > 12) return null; ts.month = month - 1; int day = IccUtils.beBcdByteToInt(data[2]); int day = IccUtils.cdmaBcdByteToInt(data[2]); if (day < 1 || day > 31) return null; ts.monthDay = day; int hour = IccUtils.beBcdByteToInt(data[3]); int hour = IccUtils.cdmaBcdByteToInt(data[3]); if (hour < 0 || hour > 23) return null; ts.hour = hour; int minute = IccUtils.beBcdByteToInt(data[4]); int minute = IccUtils.cdmaBcdByteToInt(data[4]); if (minute < 0 || minute > 59) return null; ts.minute = minute; int second = IccUtils.beBcdByteToInt(data[5]); int second = IccUtils.cdmaBcdByteToInt(data[5]); if (second < 0 || second > 59) return null; ts.second = second; return ts; Loading Loading @@ -1153,7 +1153,7 @@ public final class BearerData { if (paramBits >= EXPECTED_PARAM_SIZE) { paramBits -= EXPECTED_PARAM_SIZE; decodeSuccess = true; bData.numberOfMessages = IccUtils.beBcdByteToInt((byte)inStream.read(8)); bData.numberOfMessages = IccUtils.cdmaBcdByteToInt((byte)inStream.read(8)); } if ((! decodeSuccess) || (paramBits > 0)) { Log.d(LOG_TAG, "NUMBER_OF_MESSAGES decode " + Loading
telephony/java/com/android/internal/telephony/gsm/SmsMessage.java +8 −10 Original line number Diff line number Diff line Loading @@ -519,12 +519,12 @@ public class SmsMessage extends SmsMessageBase{ long getSCTimestampMillis() { // TP-Service-Centre-Time-Stamp int year = IccUtils.bcdByteToInt(pdu[cur++]); int month = IccUtils.bcdByteToInt(pdu[cur++]); int day = IccUtils.bcdByteToInt(pdu[cur++]); int hour = IccUtils.bcdByteToInt(pdu[cur++]); int minute = IccUtils.bcdByteToInt(pdu[cur++]); int second = IccUtils.bcdByteToInt(pdu[cur++]); int year = IccUtils.gsmBcdByteToInt(pdu[cur++]); int month = IccUtils.gsmBcdByteToInt(pdu[cur++]); int day = IccUtils.gsmBcdByteToInt(pdu[cur++]); int hour = IccUtils.gsmBcdByteToInt(pdu[cur++]); int minute = IccUtils.gsmBcdByteToInt(pdu[cur++]); int second = IccUtils.gsmBcdByteToInt(pdu[cur++]); // For the timezone, the most significant bit of the // least signficant nibble is the sign byte Loading @@ -534,11 +534,9 @@ public class SmsMessage extends SmsMessageBase{ byte tzByte = pdu[cur++]; // Mask out sign bit. int timezoneOffset = IccUtils .bcdByteToInt((byte) (tzByte & (~0x08))); int timezoneOffset = IccUtils.gsmBcdByteToInt((byte) (tzByte & (~0x08))); timezoneOffset = ((tzByte & 0x08) == 0) ? timezoneOffset : -timezoneOffset; timezoneOffset = ((tzByte & 0x08) == 0) ? timezoneOffset : -timezoneOffset; Time time = new Time(Time.TIMEZONE_UTC); Loading
tests/CoreTests/com/android/internal/telephony/SimUtilsTest.java +13 −5 Original line number Diff line number Diff line Loading @@ -44,13 +44,22 @@ public class SimUtilsTest extends TestCase { assertEquals("890", IccUtils.bcdToString(data, 0, data.length)); /* * bcdByteToInt() * gsmBcdByteToInt() */ assertEquals(98, IccUtils.bcdByteToInt((byte) 0x89)); assertEquals(98, IccUtils.gsmBcdByteToInt((byte) 0x89)); // Out of range is treated as 0 assertEquals(8, IccUtils.bcdByteToInt((byte) 0x8c)); assertEquals(8, IccUtils.gsmBcdByteToInt((byte) 0x8c)); /* * cdmaBcdByteToInt() */ assertEquals(89, IccUtils.cdmaBcdByteToInt((byte) 0x89)); // Out of range is treated as 0 assertEquals(80, IccUtils.gsmBcdByteToInt((byte) 0x8c)); /* * adnStringFieldToString() Loading @@ -76,4 +85,3 @@ public class SimUtilsTest extends TestCase { } }