Skip to content

Commit 7d16427

Browse files
author
Naveen Kalla
committed
Add subaddress to SMS fingerprint calculation.
As per SMS specification in 3GPP2 C.S0015-B, section 4.3.1.6, if the Subaddress is included in a CDMA SMS message, it needs to be used for duplicate detection. Subaddress, which is an optional field was omitted while computing the SMS fingerprint. Hence it was never being used in duplicate detection if it was included in the SMS. Add subaddress to the SMS fingerprint. Change-Id: Iad9e89887a17caba59033ab8f8d94b63b33cb4bb
1 parent 7d9c73f commit 7d16427

File tree

3 files changed

+58
-9
lines changed

3 files changed

+58
-9
lines changed

telephony/java/com/android/internal/telephony/cdma/SmsMessage.java

100755100644
Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.android.internal.telephony.TelephonyProperties;
3030
import com.android.internal.telephony.cdma.sms.BearerData;
3131
import com.android.internal.telephony.cdma.sms.CdmaSmsAddress;
32+
import com.android.internal.telephony.cdma.sms.CdmaSmsSubaddress;
3233
import com.android.internal.telephony.cdma.sms.SmsEnvelope;
3334
import com.android.internal.telephony.cdma.sms.UserData;
3435
import com.android.internal.util.HexDump;
@@ -138,6 +139,7 @@ public static SmsMessage newFromParcel(Parcel p) {
138139
SmsMessage msg = new SmsMessage();
139140
SmsEnvelope env = new SmsEnvelope();
140141
CdmaSmsAddress addr = new CdmaSmsAddress();
142+
CdmaSmsSubaddress subaddr = new CdmaSmsSubaddress();
141143
byte[] data;
142144
byte count;
143145
int countInt;
@@ -180,15 +182,24 @@ public static SmsMessage newFromParcel(Parcel p) {
180182

181183
addr.origBytes = data;
182184

183-
// ignore subaddress
184-
p.readInt(); //p_cur->sSubAddress.subaddressType
185-
p.readInt(); //p_cur->sSubAddress.odd
186-
count = p.readByte(); //p_cur->sSubAddress.number_of_digits
187-
//p_cur->sSubAddress.digits[digitCount] :
188-
for (int index=0; index < count; index++) {
189-
p.readByte();
185+
subaddr.type = p.readInt(); // p_cur->sSubAddress.subaddressType
186+
subaddr.odd = p.readByte(); // p_cur->sSubAddress.odd
187+
count = p.readByte(); // p_cur->sSubAddress.number_of_digits
188+
189+
if (count < 0) {
190+
count = 0;
190191
}
191192

193+
// p_cur->sSubAddress.digits[digitCount] :
194+
195+
data = new byte[count];
196+
197+
for (int index = 0; index < count; ++index) {
198+
data[index] = p.readByte();
199+
}
200+
201+
subaddr.origBytes = data;
202+
192203
/* currently not supported by the modem-lib:
193204
env.bearerReply
194205
env.replySeqNo
@@ -210,6 +221,7 @@ public static SmsMessage newFromParcel(Parcel p) {
210221

211222
// link the the filled objects to the SMS
212223
env.origAddress = addr;
224+
env.origSubaddress = subaddr;
213225
msg.originatingAddress = addr;
214226
msg.mEnvelope = env;
215227

@@ -818,6 +830,8 @@ private byte convertDtmfToAscii(byte dtmfDigit) {
818830
output.write(mEnvelope.teleService);
819831
output.write(mEnvelope.origAddress.origBytes, 0, mEnvelope.origAddress.origBytes.length);
820832
output.write(mEnvelope.bearerData, 0, mEnvelope.bearerData.length);
833+
output.write(mEnvelope.origSubaddress.origBytes, 0,
834+
mEnvelope.origSubaddress.origBytes.length);
821835

822836
return output.toByteArray();
823837
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (C) 2010 The Android Open Source Project. All rights reserved.
3+
* Copyright (C) 2010 Code Aurora Forum. All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package com.android.internal.telephony.cdma.sms;
19+
20+
public class CdmaSmsSubaddress {
21+
public int type;
22+
23+
public byte odd;
24+
25+
public byte[] origBytes;
26+
}
27+

telephony/java/com/android/internal/telephony/cdma/sms/SmsEnvelope.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.android.internal.telephony.cdma.sms;
1818

1919

20+
import com.android.internal.telephony.cdma.sms.CdmaSmsSubaddress;
21+
2022
public final class SmsEnvelope{
2123
/**
2224
* Message Types
@@ -74,16 +76,22 @@ public final class SmsEnvelope{
7476

7577
/**
7678
* The origination address identifies the originator of the SMS message.
77-
* (See 3GPP2 C.S0015-B, v2, 3.4.3.4)
79+
* (See 3GPP2 C.S0015-B, v2, 3.4.3.3)
7880
*/
7981
public CdmaSmsAddress origAddress;
8082

8183
/**
8284
* The destination address identifies the target of the SMS message.
83-
* (See 3GPP2 C.S0015-B, v2, 3.4.3.4)
85+
* (See 3GPP2 C.S0015-B, v2, 3.4.3.3)
8486
*/
8587
public CdmaSmsAddress destAddress;
8688

89+
/**
90+
* The origination subaddress identifies the originator of the SMS message.
91+
* (See 3GPP2 C.S0015-B, v2, 3.4.3.4)
92+
*/
93+
public CdmaSmsSubaddress origSubaddress;
94+
8795
/**
8896
* The 6-bit bearer reply parameter is used to request the return of a
8997
* SMS Acknowledge Message.

0 commit comments

Comments
 (0)