Skip to content

Commit ac09d2a

Browse files
author
Jake Hamby
committed
Add support for SMS-PP data download to USIM.
Devices supporting IMS may receive SMS-PP data download messages which are normally handled in the radio baseband. Add support to framework for these messages, passing the data to the UICC and sending the response data as part of the SMS ACK. Change-Id: I1da76982c6f8c402f82a6f535591e614f4e0de18
1 parent ab5040c commit ac09d2a

File tree

14 files changed

+1191
-59
lines changed

14 files changed

+1191
-59
lines changed

telephony/java/com/android/internal/telephony/CommandsInterface.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ public boolean isCdma() {
157157

158158
// GSM SMS fail cause for acknowledgeLastIncomingSMS. From TS 23.040, 9.2.3.22.
159159
static final int GSM_SMS_FAIL_CAUSE_MEMORY_CAPACITY_EXCEEDED = 0xD3;
160+
static final int GSM_SMS_FAIL_CAUSE_USIM_APP_TOOLKIT_BUSY = 0xD4;
161+
static final int GSM_SMS_FAIL_CAUSE_USIM_DATA_DOWNLOAD_ERROR = 0xD5;
160162
static final int GSM_SMS_FAIL_CAUSE_UNSPECIFIED_ERROR = 0xFF;
161163

162164
// CDMA SMS fail cause for acknowledgeLastIncomingCdmaSms. From TS N.S0005, 6.5.2.125.

telephony/java/com/android/internal/telephony/IccIoResult.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
*/
2222
public class
2323
IccIoResult {
24-
int sw1;
25-
int sw2;
24+
public int sw1;
25+
public int sw2;
2626

2727
public byte[] payload;
2828

telephony/java/com/android/internal/telephony/IccRecords.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.os.Registrant;
2323
import android.os.RegistrantList;
2424

25+
import com.android.internal.telephony.gsm.UsimServiceTable;
2526
import com.android.internal.telephony.ims.IsimRecords;
2627

2728
/**
@@ -362,4 +363,8 @@ public boolean isProvisioned () {
362363
public IsimRecords getIsimRecords() {
363364
return null;
364365
}
366+
367+
public UsimServiceTable getUsimServiceTable() {
368+
return null;
369+
}
365370
}

telephony/java/com/android/internal/telephony/Phone.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import android.telephony.SignalStrength;
2929

3030
import com.android.internal.telephony.DataConnection;
31+
import com.android.internal.telephony.gsm.UsimServiceTable;
3132
import com.android.internal.telephony.ims.IsimRecords;
3233
import com.android.internal.telephony.test.SimulatedRadioControl;
3334

@@ -1765,4 +1766,10 @@ void selectNetworkManually(OperatorInfo network,
17651766
* messages are waiting
17661767
*/
17671768
void setVoiceMessageWaiting(int line, int countWaiting);
1769+
1770+
/**
1771+
* Gets the USIM service table from the UICC, if present and available.
1772+
* @return an interface to the UsimServiceTable record, or null if not available
1773+
*/
1774+
UsimServiceTable getUsimServiceTable();
17681775
}

telephony/java/com/android/internal/telephony/PhoneBase.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import android.util.Log;
3838

3939
import com.android.internal.R;
40+
import com.android.internal.telephony.gsm.UsimServiceTable;
4041
import com.android.internal.telephony.ims.IsimRecords;
4142
import com.android.internal.telephony.test.SimulatedRadioControl;
4243
import com.android.internal.telephony.gsm.SIMRecords;
@@ -1178,4 +1179,13 @@ public int getLteOnCdmaMode() {
11781179
public void setVoiceMessageWaiting(int line, int countWaiting) {
11791180
mIccRecords.setVoiceMessageWaiting(line, countWaiting);
11801181
}
1182+
1183+
/**
1184+
* Gets the USIM service table from the UICC, if present and available.
1185+
* @return an interface to the UsimServiceTable record, or null if not available
1186+
*/
1187+
@Override
1188+
public UsimServiceTable getUsimServiceTable() {
1189+
return mIccRecords.getUsimServiceTable();
1190+
}
11811191
}

telephony/java/com/android/internal/telephony/PhoneProxy.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
import com.android.internal.telephony.cdma.CDMAPhone;
3434
import com.android.internal.telephony.gsm.GSMPhone;
35+
import com.android.internal.telephony.gsm.UsimServiceTable;
3536
import com.android.internal.telephony.ims.IsimRecords;
3637
import com.android.internal.telephony.test.SimulatedRadioControl;
3738

@@ -853,4 +854,9 @@ public int getLteOnCdmaMode() {
853854
public void setVoiceMessageWaiting(int line, int countWaiting) {
854855
mActivePhone.setVoiceMessageWaiting(line, countWaiting);
855856
}
857+
858+
@Override
859+
public UsimServiceTable getUsimServiceTable() {
860+
return mActivePhone.getUsimServiceTable();
861+
}
856862
}

telephony/java/com/android/internal/telephony/cat/CatService.java

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -34,61 +34,6 @@
3434
import java.io.ByteArrayOutputStream;
3535
import java.util.Locale;
3636

37-
/**
38-
* Enumeration for representing the tag value of COMPREHENSION-TLV objects. If
39-
* you want to get the actual value, call {@link #value() value} method.
40-
*
41-
* {@hide}
42-
*/
43-
enum ComprehensionTlvTag {
44-
COMMAND_DETAILS(0x01),
45-
DEVICE_IDENTITIES(0x02),
46-
RESULT(0x03),
47-
DURATION(0x04),
48-
ALPHA_ID(0x05),
49-
USSD_STRING(0x0a),
50-
TEXT_STRING(0x0d),
51-
TONE(0x0e),
52-
ITEM(0x0f),
53-
ITEM_ID(0x10),
54-
RESPONSE_LENGTH(0x11),
55-
FILE_LIST(0x12),
56-
HELP_REQUEST(0x15),
57-
DEFAULT_TEXT(0x17),
58-
EVENT_LIST(0x19),
59-
ICON_ID(0x1e),
60-
ITEM_ICON_ID_LIST(0x1f),
61-
IMMEDIATE_RESPONSE(0x2b),
62-
LANGUAGE(0x2d),
63-
URL(0x31),
64-
BROWSER_TERMINATION_CAUSE(0x34),
65-
TEXT_ATTRIBUTE(0x50);
66-
67-
private int mValue;
68-
69-
ComprehensionTlvTag(int value) {
70-
mValue = value;
71-
}
72-
73-
/**
74-
* Returns the actual value of this COMPREHENSION-TLV object.
75-
*
76-
* @return Actual tag value of this object
77-
*/
78-
public int value() {
79-
return mValue;
80-
}
81-
82-
public static ComprehensionTlvTag fromInt(int value) {
83-
for (ComprehensionTlvTag e : ComprehensionTlvTag.values()) {
84-
if (e.mValue == value) {
85-
return e;
86-
}
87-
}
88-
return null;
89-
}
90-
}
91-
9237
class RilMessage {
9338
int mId;
9439
Object mData;
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (C) 2011 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.android.internal.telephony.cat;
18+
19+
/**
20+
* Enumeration for representing the tag value of COMPREHENSION-TLV objects. If
21+
* you want to get the actual value, call {@link #value() value} method.
22+
*
23+
* {@hide}
24+
*/
25+
public enum ComprehensionTlvTag {
26+
COMMAND_DETAILS(0x01),
27+
DEVICE_IDENTITIES(0x02),
28+
RESULT(0x03),
29+
DURATION(0x04),
30+
ALPHA_ID(0x05),
31+
ADDRESS(0x06),
32+
USSD_STRING(0x0a),
33+
SMS_TPDU(0x0b),
34+
TEXT_STRING(0x0d),
35+
TONE(0x0e),
36+
ITEM(0x0f),
37+
ITEM_ID(0x10),
38+
RESPONSE_LENGTH(0x11),
39+
FILE_LIST(0x12),
40+
HELP_REQUEST(0x15),
41+
DEFAULT_TEXT(0x17),
42+
EVENT_LIST(0x19),
43+
ICON_ID(0x1e),
44+
ITEM_ICON_ID_LIST(0x1f),
45+
IMMEDIATE_RESPONSE(0x2b),
46+
LANGUAGE(0x2d),
47+
URL(0x31),
48+
BROWSER_TERMINATION_CAUSE(0x34),
49+
TEXT_ATTRIBUTE(0x50);
50+
51+
private int mValue;
52+
53+
ComprehensionTlvTag(int value) {
54+
mValue = value;
55+
}
56+
57+
/**
58+
* Returns the actual value of this COMPREHENSION-TLV object.
59+
*
60+
* @return Actual tag value of this object
61+
*/
62+
public int value() {
63+
return mValue;
64+
}
65+
66+
public static ComprehensionTlvTag fromInt(int value) {
67+
for (ComprehensionTlvTag e : ComprehensionTlvTag.values()) {
68+
if (e.mValue == value) {
69+
return e;
70+
}
71+
}
72+
return null;
73+
}
74+
}

telephony/java/com/android/internal/telephony/gsm/GsmSMSDispatcher.java

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
import android.os.SystemProperties;
2626
import android.provider.Telephony.Sms;
2727
import android.provider.Telephony.Sms.Intents;
28-
import android.telephony.ServiceState;
28+
import android.telephony.PhoneNumberUtils;
2929
import android.telephony.SmsCbMessage;
30+
import android.telephony.SmsManager;
3031
import android.telephony.gsm.GsmCellLocation;
3132
import android.util.Log;
3233

@@ -41,7 +42,6 @@
4142
import com.android.internal.telephony.SmsUsageMonitor;
4243
import com.android.internal.telephony.TelephonyProperties;
4344

44-
import java.util.ArrayList;
4545
import java.util.HashMap;
4646
import java.util.Iterator;
4747

@@ -56,9 +56,16 @@ public final class GsmSMSDispatcher extends SMSDispatcher {
5656
/** New broadcast SMS */
5757
private static final int EVENT_NEW_BROADCAST_SMS = 101;
5858

59+
/** Result of writing SM to UICC (when SMS-PP service is not available). */
60+
private static final int EVENT_WRITE_SMS_COMPLETE = 102;
61+
62+
/** Handler for SMS-PP data download messages to UICC. */
63+
private final UsimDataDownloadHandler mDataDownloadHandler;
64+
5965
public GsmSMSDispatcher(PhoneBase phone, SmsStorageMonitor storageMonitor,
6066
SmsUsageMonitor usageMonitor) {
6167
super(phone, storageMonitor, usageMonitor);
68+
mDataDownloadHandler = new UsimDataDownloadHandler(mCm);
6269
mCm.setOnNewGsmSms(this, EVENT_NEW_SMS, null);
6370
mCm.setOnSmsStatus(this, EVENT_NEW_SMS_STATUS_REPORT, null);
6471
mCm.setOnNewGsmBroadcastSms(this, EVENT_NEW_BROADCAST_SMS, null);
@@ -93,6 +100,18 @@ public void handleMessage(Message msg) {
93100
handleBroadcastSms((AsyncResult)msg.obj);
94101
break;
95102

103+
case EVENT_WRITE_SMS_COMPLETE:
104+
AsyncResult ar = (AsyncResult) msg.obj;
105+
if (ar.exception == null) {
106+
Log.d(TAG, "Successfully wrote SMS-PP message to UICC");
107+
mCm.acknowledgeLastIncomingGsmSms(true, 0, null);
108+
} else {
109+
Log.d(TAG, "Failed to write SMS-PP message to UICC", ar.exception);
110+
mCm.acknowledgeLastIncomingGsmSms(false,
111+
CommandsInterface.GSM_SMS_FAIL_CAUSE_UNSPECIFIED_ERROR, null);
112+
}
113+
break;
114+
96115
default:
97116
super.handleMessage(msg);
98117
}
@@ -154,6 +173,29 @@ public int dispatchMessage(SmsMessageBase smsb) {
154173
return Intents.RESULT_SMS_HANDLED;
155174
}
156175

176+
// Send SMS-PP data download messages to UICC. See 3GPP TS 31.111 section 7.1.1.
177+
if (sms.isUsimDataDownload()) {
178+
UsimServiceTable ust = mPhone.getUsimServiceTable();
179+
// If we receive an SMS-PP message before the UsimServiceTable has been loaded,
180+
// assume that the data download service is not present. This is very unlikely to
181+
// happen because the IMS connection will not be established until after the ISIM
182+
// records have been loaded, after the USIM service table has been loaded.
183+
if (ust != null && ust.isAvailable(
184+
UsimServiceTable.UsimService.DATA_DL_VIA_SMS_PP)) {
185+
Log.d(TAG, "Received SMS-PP data download, sending to UICC.");
186+
return mDataDownloadHandler.startDataDownload(sms);
187+
} else {
188+
Log.d(TAG, "DATA_DL_VIA_SMS_PP service not available, storing message to UICC.");
189+
String smsc = IccUtils.bytesToHexString(
190+
PhoneNumberUtils.networkPortionToCalledPartyBCDWithLength(
191+
sms.getServiceCenterAddress()));
192+
mCm.writeSmsToSim(SmsManager.STATUS_ON_ICC_UNREAD, smsc,
193+
IccUtils.bytesToHexString(sms.getPdu()),
194+
obtainMessage(EVENT_WRITE_SMS_COMPLETE));
195+
return Activity.RESULT_OK; // acknowledge after response from write to USIM
196+
}
197+
}
198+
157199
if (mSmsReceiveDisabled) {
158200
// Device doesn't support SMS service,
159201
Log.d(TAG, "Received short message on device which doesn't support "

telephony/java/com/android/internal/telephony/gsm/SIMRecords.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ public String getMsisdnNumber() {
248248
return msisdn;
249249
}
250250

251+
@Override
251252
public UsimServiceTable getUsimServiceTable() {
252253
return mUsimServiceTable;
253254
}

0 commit comments

Comments
 (0)