Skip to content

Commit a625e1f

Browse files
Jake HambyAndroid (Google) Code Review
authored andcommitted
Merge "Add wrapper classes for UICC service tables."
2 parents 48019c6 + 4db49b3 commit a625e1f

File tree

7 files changed

+398
-6
lines changed

7 files changed

+398
-6
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public abstract class IccRecords extends Handler implements IccConstants {
5757
protected int mailboxIndex = 0; // 0 is no mailbox dailing number associated
5858

5959
protected String spn;
60-
protected int spnDisplayCondition;
6160

6261
// ***** Constants
6362

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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;
18+
19+
import android.util.Log;
20+
21+
/**
22+
* Wrapper class for an ICC EF containing a bit field of enabled services.
23+
*/
24+
public abstract class IccServiceTable {
25+
protected final byte[] mServiceTable;
26+
27+
protected IccServiceTable(byte[] table) {
28+
mServiceTable = table;
29+
}
30+
31+
// Get the class name to use for log strings
32+
protected abstract String getTag();
33+
34+
// Get the array of enums to use for toString
35+
protected abstract Object[] getValues();
36+
37+
/**
38+
* Returns if the specified service is available.
39+
* @param service the service number as a zero-based offset (the enum ordinal)
40+
* @return true if the service is available; false otherwise
41+
*/
42+
protected boolean isAvailable(int service) {
43+
int offset = service / 8;
44+
if (offset >= mServiceTable.length) {
45+
// Note: Enums are zero-based, but the TS service numbering is one-based
46+
Log.e(getTag(), "isAvailable for service " + (service + 1) + " fails, max service is " +
47+
(mServiceTable.length * 8));
48+
return false;
49+
}
50+
int bit = service % 8;
51+
return (mServiceTable[offset] & (1 << bit)) != 0;
52+
}
53+
54+
public String toString() {
55+
Object[] values = getValues();
56+
int numBytes = mServiceTable.length;
57+
StringBuilder builder = new StringBuilder(getTag()).append('[')
58+
.append(numBytes * 8).append("]={ ");
59+
60+
boolean addComma = false;
61+
for (int i = 0; i < numBytes; i++) {
62+
byte currentByte = mServiceTable[i];
63+
for (int bit = 0; bit < 8; bit++) {
64+
if ((currentByte & (1 << bit)) != 0) {
65+
if (addComma) {
66+
builder.append(", ");
67+
} else {
68+
addComma = true;
69+
}
70+
int ordinal = (i * 8) + bit;
71+
if (ordinal < values.length) {
72+
builder.append(values[ordinal]);
73+
} else {
74+
builder.append('#').append(ordinal + 1); // service number (one-based)
75+
}
76+
}
77+
}
78+
}
79+
return builder.append(" }").toString();
80+
}
81+
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ protected void fetchSimRecords() {
282282
obtainMessage(EVENT_GET_MSISDN_DONE));
283283
recordsToLoad++;
284284

285+
iccFh.loadEFTransparent(EF_SST, obtainMessage(EVENT_GET_SST_DONE));
286+
recordsToLoad++;
287+
285288
iccFh.loadEFTransparent(EF_CSIM_LI,
286289
obtainMessage(EVENT_GET_ICC_RECORD_DONE, new EfCsimLiLoaded()));
287290
recordsToLoad++;
@@ -384,12 +387,12 @@ private String findBestLanguage(byte[] languages) {
384387

385388
@Override
386389
protected void log(String s) {
387-
if (DBG) Log.d(LOG_TAG, "[CSIM] " + s);
390+
Log.d(LOG_TAG, "[CSIM] " + s);
388391
}
389392

390393
@Override
391394
protected void loge(String s) {
392-
if (DBG) Log.e(LOG_TAG, "[CSIM] " + s);
395+
Log.e(LOG_TAG, "[CSIM] " + s);
393396
}
394397

395398
public String getMdn() {

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public class SIMRecords extends IccRecords {
9191

9292
String pnnHomeName = null;
9393

94+
UsimServiceTable mUsimServiceTable;
95+
9496
// ***** Constants
9597

9698
// Bitmasks for SPN display rules.
@@ -134,7 +136,7 @@ public class SIMRecords extends IccRecords {
134136
private static final int EVENT_GET_SPDI_DONE = 13;
135137
private static final int EVENT_UPDATE_DONE = 14;
136138
private static final int EVENT_GET_PNN_DONE = 15;
137-
private static final int EVENT_GET_SST_DONE = 17;
139+
protected static final int EVENT_GET_SST_DONE = 17;
138140
private static final int EVENT_GET_ALL_SMS_DONE = 18;
139141
private static final int EVENT_MARK_SMS_READ_DONE = 19;
140142
private static final int EVENT_SET_MBDN_DONE = 20;
@@ -246,6 +248,10 @@ public String getMsisdnNumber() {
246248
return msisdn;
247249
}
248250

251+
public UsimServiceTable getUsimServiceTable() {
252+
return mUsimServiceTable;
253+
}
254+
249255
/**
250256
* Set subscriber number to SIM record
251257
*
@@ -961,8 +967,9 @@ public void handleMessage(Message msg) {
961967
break;
962968
}
963969

964-
//Log.d(LOG_TAG, "SST: " + IccUtils.bytesToHexString(data));
965-
break;
970+
mUsimServiceTable = new UsimServiceTable(data);
971+
if (DBG) log("SST: " + mUsimServiceTable);
972+
break;
966973

967974
case EVENT_GET_INFO_CPHS_DONE:
968975
isRecordLoadResponse = true;
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
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.gsm;
18+
19+
import com.android.internal.telephony.IccServiceTable;
20+
21+
/**
22+
* Wrapper class for the USIM Service Table EF.
23+
* See 3GPP TS 31.102 Release 10 section 4.2.8
24+
*/
25+
public final class UsimServiceTable extends IccServiceTable {
26+
public enum UsimService {
27+
PHONEBOOK,
28+
FDN, // Fixed Dialing Numbers
29+
FDN_EXTENSION, // FDN extension data in EF_EXT2
30+
SDN, // Service Dialing Numbers
31+
SDN_EXTENSION, // SDN extension data in EF_EXT3
32+
BDN, // Barred Dialing Numbers
33+
BDN_EXTENSION, // BDN extension data in EF_EXT4
34+
OUTGOING_CALL_INFO,
35+
INCOMING_CALL_INFO,
36+
SM_STORAGE,
37+
SM_STATUS_REPORTS,
38+
SM_SERVICE_PARAMS,
39+
ADVICE_OF_CHARGE,
40+
CAP_CONFIG_PARAMS_2,
41+
CB_MESSAGE_ID,
42+
CB_MESSAGE_ID_RANGES,
43+
GROUP_ID_LEVEL_1,
44+
GROUP_ID_LEVEL_2,
45+
SPN, // Service Provider Name
46+
USER_PLMN_SELECT,
47+
MSISDN,
48+
IMAGE,
49+
LOCALISED_SERVICE_AREAS,
50+
EMLPP, // Enhanced Multi-Level Precedence and Preemption
51+
EMLPP_AUTO_ANSWER,
52+
RFU,
53+
GSM_ACCESS,
54+
DATA_DL_VIA_SMS_PP,
55+
DATA_DL_VIA_SMS_CB,
56+
CALL_CONTROL_BY_USIM,
57+
MO_SMS_CONTROL_BY_USIM,
58+
RUN_AT_COMMAND,
59+
IGNORED_1,
60+
ENABLED_SERVICES_TABLE,
61+
APN_CONTROL_LIST,
62+
DEPERSONALISATION_CONTROL_KEYS,
63+
COOPERATIVE_NETWORK_LIST,
64+
GSM_SECURITY_CONTEXT,
65+
CPBCCH_INFO,
66+
INVESTIGATION_SCAN,
67+
MEXE,
68+
OPERATOR_PLMN_SELECT,
69+
HPLMN_SELECT,
70+
EXTENSION_5, // Extension data for ICI, OCI, MSISDN in EF_EXT5
71+
PLMN_NETWORK_NAME,
72+
OPERATOR_PLMN_LIST,
73+
MBDN, // Mailbox Dialing Numbers
74+
MWI_STATUS, // Message Waiting Indication status
75+
CFI_STATUS, // Call Forwarding Indication status
76+
IGNORED_2,
77+
SERVICE_PROVIDER_DISPLAY_INFO,
78+
MMS_NOTIFICATION,
79+
MMS_NOTIFICATION_EXTENSION, // MMS Notification extension data in EF_EXT8
80+
GPRS_CALL_CONTROL_BY_USIM,
81+
MMS_CONNECTIVITY_PARAMS,
82+
NETWORK_INDICATION_OF_ALERTING,
83+
VGCS_GROUP_ID_LIST,
84+
VBS_GROUP_ID_LIST,
85+
PSEUDONYM,
86+
IWLAN_USER_PLMN_SELECT,
87+
IWLAN_OPERATOR_PLMN_SELECT,
88+
USER_WSID_LIST,
89+
OPERATOR_WSID_LIST,
90+
VGCS_SECURITY,
91+
VBS_SECURITY,
92+
WLAN_REAUTH_IDENTITY,
93+
MM_STORAGE,
94+
GBA, // Generic Bootstrapping Architecture
95+
MBMS_SECURITY,
96+
DATA_DL_VIA_USSD,
97+
EQUIVALENT_HPLMN,
98+
TERMINAL_PROFILE_AFTER_UICC_ACTIVATION,
99+
EQUIVALENT_HPLMN_PRESENTATION,
100+
LAST_RPLMN_SELECTION_INDICATION,
101+
OMA_BCAST_PROFILE,
102+
GBA_LOCAL_KEY_ESTABLISHMENT,
103+
TERMINAL_APPLICATIONS,
104+
SPN_ICON,
105+
PLMN_NETWORK_NAME_ICON,
106+
USIM_IP_CONNECTION_PARAMS,
107+
IWLAN_HOME_ID_LIST,
108+
IWLAN_EQUIVALENT_HPLMN_PRESENTATION,
109+
IWLAN_HPLMN_PRIORITY_INDICATION,
110+
IWLAN_LAST_REGISTERED_PLMN,
111+
EPS_MOBILITY_MANAGEMENT_INFO,
112+
ALLOWED_CSG_LISTS_AND_INDICATIONS,
113+
CALL_CONTROL_ON_EPS_PDN_CONNECTION_BY_USIM,
114+
HPLMN_DIRECT_ACCESS,
115+
ECALL_DATA,
116+
OPERATOR_CSG_LISTS_AND_INDICATIONS,
117+
SM_OVER_IP,
118+
CSG_DISPLAY_CONTROL,
119+
IMS_COMMUNICATION_CONTROL_BY_USIM,
120+
EXTENDED_TERMINAL_APPLICATIONS,
121+
UICC_ACCESS_TO_IMS,
122+
NAS_CONFIG_BY_USIM
123+
}
124+
125+
public UsimServiceTable(byte[] table) {
126+
super(table);
127+
}
128+
129+
public boolean isAvailable(UsimService service) {
130+
return super.isAvailable(service.ordinal());
131+
}
132+
133+
@Override
134+
protected String getTag() {
135+
return "UsimServiceTable";
136+
}
137+
138+
@Override
139+
protected Object[] getValues() {
140+
return UsimService.values();
141+
}
142+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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;
18+
19+
import android.test.AndroidTestCase;
20+
import android.test.suitebuilder.annotation.SmallTest;
21+
22+
/**
23+
* Test IccServiceTable class.
24+
*/
25+
public class IccServiceTableTest extends AndroidTestCase {
26+
27+
static class TestIccServiceTable extends IccServiceTable {
28+
public enum TestIccService {
29+
SERVICE1,
30+
SERVICE2,
31+
SERVICE3,
32+
SERVICE4
33+
}
34+
35+
public TestIccServiceTable(byte[] table) {
36+
super(table);
37+
}
38+
39+
public boolean isAvailable(TestIccService service) {
40+
return super.isAvailable(service.ordinal());
41+
}
42+
43+
@Override
44+
protected String getTag() {
45+
return "TestIccServiceTable";
46+
}
47+
48+
@Override
49+
protected Object[] getValues() {
50+
return TestIccService.values();
51+
}
52+
}
53+
54+
@SmallTest
55+
public void testIccServiceTable() {
56+
byte[] noServices = {0x00};
57+
byte[] service1 = {0x01};
58+
byte[] service4 = {0x08};
59+
byte[] allServices = {0x0f};
60+
61+
TestIccServiceTable testTable1 = new TestIccServiceTable(noServices);
62+
assertFalse(testTable1.isAvailable(TestIccServiceTable.TestIccService.SERVICE1));
63+
assertFalse(testTable1.isAvailable(TestIccServiceTable.TestIccService.SERVICE2));
64+
assertFalse(testTable1.isAvailable(TestIccServiceTable.TestIccService.SERVICE3));
65+
assertFalse(testTable1.isAvailable(TestIccServiceTable.TestIccService.SERVICE4));
66+
67+
TestIccServiceTable testTable2 = new TestIccServiceTable(service1);
68+
assertTrue(testTable2.isAvailable(TestIccServiceTable.TestIccService.SERVICE1));
69+
assertFalse(testTable2.isAvailable(TestIccServiceTable.TestIccService.SERVICE2));
70+
assertFalse(testTable2.isAvailable(TestIccServiceTable.TestIccService.SERVICE3));
71+
assertFalse(testTable2.isAvailable(TestIccServiceTable.TestIccService.SERVICE4));
72+
73+
TestIccServiceTable testTable3 = new TestIccServiceTable(service4);
74+
assertFalse(testTable3.isAvailable(TestIccServiceTable.TestIccService.SERVICE1));
75+
assertFalse(testTable3.isAvailable(TestIccServiceTable.TestIccService.SERVICE2));
76+
assertFalse(testTable3.isAvailable(TestIccServiceTable.TestIccService.SERVICE3));
77+
assertTrue(testTable3.isAvailable(TestIccServiceTable.TestIccService.SERVICE4));
78+
79+
TestIccServiceTable testTable4 = new TestIccServiceTable(allServices);
80+
assertTrue(testTable4.isAvailable(TestIccServiceTable.TestIccService.SERVICE1));
81+
assertTrue(testTable4.isAvailable(TestIccServiceTable.TestIccService.SERVICE2));
82+
assertTrue(testTable4.isAvailable(TestIccServiceTable.TestIccService.SERVICE3));
83+
assertTrue(testTable4.isAvailable(TestIccServiceTable.TestIccService.SERVICE4));
84+
}
85+
}

0 commit comments

Comments
 (0)