From 98a5ba78f99f6537b34b673521f7d4ab9893c80b Mon Sep 17 00:00:00 2001 From: Tammo Spalink Date: Wed, 9 Sep 2009 11:32:25 +0800 Subject: Avoid CDMA messages with IDs of zero. In reference to issue: http://buganizer/issue?id=2047571 Change-Id: I88b5cdbb988f12206663bbb3fdc9508a437b19ad --- .../internal/telephony/cdma/SmsMessage.java | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java index 2c20784..d17468c 100755 --- a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java +++ b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java @@ -598,21 +598,20 @@ public class SmsMessage extends SmsMessageBase { } /** - * Calculate the next message id, starting at 0 and iteratively - * incrementing within the range 0..65535 remembering the state + * Calculate the next message id, starting at 1 and iteratively + * incrementing within the range 1..65535 remembering the state * 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() { - // The only (meaningful) way this code can be called is via - // binder-call into the Phone process. All other calls will - // assumedly not be as with UID radio, and hence will be - // unable to modify the system property. Synchronization has - // thus been added to this function conservatively -- if it - // can be conclusively reasoned to be unnecessary, it should - // be removed. - int msgId = SystemProperties.getInt(TelephonyProperties.PROPERTY_CDMA_MSG_ID, 0); - String nextMsgId = Integer.toString((msgId + 1) & 0xFFFF); + // Testing and dialog with partners has indicated that + // msgId==0 is (sometimes?) treated specially by lower levels. + // Specifically, the ID is not preserved for delivery ACKs. + // Hence, avoid 0 -- constraining the range to 1..65535. + int msgId = SystemProperties.getInt(TelephonyProperties.PROPERTY_CDMA_MSG_ID, 1); + String nextMsgId = Integer.toString((msgId % 0xFFFF) + 1); SystemProperties.set(TelephonyProperties.PROPERTY_CDMA_MSG_ID, nextMsgId); if (DBG_SMS) { Log.d(LOG_TAG, "next " + TelephonyProperties.PROPERTY_CDMA_MSG_ID + " = " + nextMsgId); -- cgit v1.1