Merge change 24318 into eclair

* changes:
  Avoid CDMA messages with IDs of zero.
This commit is contained in:
Android (Google) Code Review
2009-09-08 22:55:49 -07:00

View File

@@ -598,21 +598,20 @@ public class SmsMessage extends SmsMessageBase {
} }
/** /**
* Calculate the next message id, starting at 0 and iteratively * Calculate the next message id, starting at 1 and iteratively
* incrementing within the range 0..65535 remembering the state * incrementing within the range 1..65535 remembering the state
* via a persistent system property. (See C.S0015-B, v2.0, * via a persistent system property. (See C.S0015-B, v2.0,
* 4.3.1.5) * 4.3.1.5) Since this routine is expected to be accessed via via
* binder-call, and hence should be threadsafe, it has been
* synchronized.
*/ */
private synchronized static int getNextMessageId() { private synchronized static int getNextMessageId() {
// The only (meaningful) way this code can be called is via // Testing and dialog with partners has indicated that
// binder-call into the Phone process. All other calls will // msgId==0 is (sometimes?) treated specially by lower levels.
// assumedly not be as with UID radio, and hence will be // Specifically, the ID is not preserved for delivery ACKs.
// unable to modify the system property. Synchronization has // Hence, avoid 0 -- constraining the range to 1..65535.
// thus been added to this function conservatively -- if it int msgId = SystemProperties.getInt(TelephonyProperties.PROPERTY_CDMA_MSG_ID, 1);
// can be conclusively reasoned to be unnecessary, it should String nextMsgId = Integer.toString((msgId % 0xFFFF) + 1);
// be removed.
int msgId = SystemProperties.getInt(TelephonyProperties.PROPERTY_CDMA_MSG_ID, 0);
String nextMsgId = Integer.toString((msgId + 1) & 0xFFFF);
SystemProperties.set(TelephonyProperties.PROPERTY_CDMA_MSG_ID, nextMsgId); SystemProperties.set(TelephonyProperties.PROPERTY_CDMA_MSG_ID, nextMsgId);
if (DBG_SMS) { if (DBG_SMS) {
Log.d(LOG_TAG, "next " + TelephonyProperties.PROPERTY_CDMA_MSG_ID + " = " + nextMsgId); Log.d(LOG_TAG, "next " + TelephonyProperties.PROPERTY_CDMA_MSG_ID + " = " + nextMsgId);