am af8a9bd4: am 8460be7a: Merge change 25535 into eclair

Merge commit 'af8a9bd4cb4803d9eb6899bd229a0bff54951c55'

* commit 'af8a9bd4cb4803d9eb6899bd229a0bff54951c55':
  CDMA Check for network duplicate sms
This commit is contained in:
Christian Gustafsson
2009-09-17 12:24:04 -07:00
committed by Android Git Automerger
2 changed files with 33 additions and 2 deletions

View File

@@ -48,6 +48,7 @@ import com.android.internal.util.HexDump;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.lang.Boolean;
@@ -57,6 +58,9 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
private CDMAPhone mCdmaPhone;
private byte[] mLastDispatchedSmsFingerprint;
private byte[] mLastAcknowledgedSmsFingerprint;
CdmaSMSDispatcher(CDMAPhone phone) {
super(phone);
mCdmaPhone = phone;
@@ -104,8 +108,14 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
return Intents.RESULT_SMS_GENERIC_ERROR;
}
// Decode BD stream and set sms variables.
// See if we have a network duplicate SMS.
SmsMessage sms = (SmsMessage) smsb;
mLastDispatchedSmsFingerprint = sms.getIncomingSmsFingerprint();
if (mLastAcknowledgedSmsFingerprint != null &&
Arrays.equals(mLastDispatchedSmsFingerprint, mLastAcknowledgedSmsFingerprint)) {
return Intents.RESULT_SMS_HANDLED;
}
// Decode BD stream and set sms variables.
sms.parseSms();
int teleService = sms.getTeleService();
boolean handled = false;
@@ -433,7 +443,13 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
}
if (mCm != null) {
mCm.acknowledgeLastIncomingCdmaSms(success, resultToCause(result), response);
int causeCode = resultToCause(result);
mCm.acknowledgeLastIncomingCdmaSms(success, causeCode, response);
if (causeCode == 0) {
mLastAcknowledgedSmsFingerprint = mLastDispatchedSmsFingerprint;
}
mLastDispatchedSmsFingerprint = null;
}
}

View File

@@ -794,5 +794,20 @@ public class SmsMessage extends SmsMessageBase {
return mBearerData.numberOfMessages;
}
/**
* Returns a byte array that can be use to uniquely identify a received SMS message.
* C.S0015-B 4.3.1.6 Unique Message Identification.
*
* @return byte array uniquely identifying the message.
* @hide
*/
/* package */ byte[] getIncomingSmsFingerprint() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
output.write(mEnvelope.teleService);
output.write(mEnvelope.origAddress.origBytes, 0, mEnvelope.origAddress.origBytes.length);
output.write(mEnvelope.bearerData, 0, mEnvelope.bearerData.length);
return output.toByteArray();
}
}