Rename bcdByteToInt to gsmBcdByteToInt and beBcdByteToInt to cdmaBcdByteToInt.
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
@@ -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 " +
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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()
|
||||
@@ -76,4 +85,3 @@ public class SimUtilsTest extends TestCase {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user