1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
subscriptLoader.loadSubScript("resource://gre/modules/ril_consts.js", this);
function run_test() {
run_next_test();
}
add_test(function test_personalization_state() {
let worker = newUint8Worker();
let context = worker.ContextPool._contexts[0];
let ril = context.RIL;
context.ICCRecordHelper.readICCID = function fakeReadICCID() {};
function testPersonalization(isCdma, cardPersoState, geckoCardState) {
let iccStatus = {
cardState: CARD_STATE_PRESENT,
gsmUmtsSubscriptionAppIndex: (!isCdma) ? 0 : -1,
cdmaSubscriptionAppIndex: (isCdma) ? 0 : -1,
apps: [
{
app_state: CARD_APPSTATE_SUBSCRIPTION_PERSO,
perso_substate: cardPersoState
}],
};
ril._isCdma = isCdma;
ril._processICCStatus(iccStatus);
equal(ril.cardState, geckoCardState);
}
// Test GSM personalization state.
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_NETWORK,
Ci.nsIIcc.CARD_STATE_NETWORK_LOCKED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_NETWORK_SUBSET,
Ci.nsIIcc.CARD_STATE_NETWORK_SUBSET_LOCKED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_CORPORATE,
Ci.nsIIcc.CARD_STATE_CORPORATE_LOCKED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER,
Ci.nsIIcc.CARD_STATE_SERVICE_PROVIDER_LOCKED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_SIM,
Ci.nsIIcc.CARD_STATE_SIM_LOCKED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_NETWORK_PUK,
Ci.nsIIcc.CARD_STATE_NETWORK_PUK_REQUIRED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK,
Ci.nsIIcc.CARD_STATE_NETWORK_SUBSET_PUK_REQUIRED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_CORPORATE_PUK,
Ci.nsIIcc.CARD_STATE_CORPORATE_PUK_REQUIRED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK,
Ci.nsIIcc.CARD_STATE_SERVICE_PROVIDER_PUK_REQUIRED);
testPersonalization(false, CARD_PERSOSUBSTATE_SIM_SIM_PUK,
Ci.nsIIcc.CARD_STATE_SIM_PUK_REQUIRED);
testPersonalization(false, CARD_PERSOSUBSTATE_UNKNOWN,
Ci.nsIIcc.CARD_STATE_UNKNOWN);
testPersonalization(false, CARD_PERSOSUBSTATE_IN_PROGRESS,
Ci.nsIIcc.CARD_STATE_PERSONALIZATION_IN_PROGRESS);
testPersonalization(false, CARD_PERSOSUBSTATE_READY,
Ci.nsIIcc.CARD_STATE_PERSONALIZATION_READY);
// Test CDMA personalization state.
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_NETWORK1,
Ci.nsIIcc.CARD_STATE_NETWORK1_LOCKED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_NETWORK2,
Ci.nsIIcc.CARD_STATE_NETWORK2_LOCKED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_HRPD,
Ci.nsIIcc.CARD_STATE_HRPD_NETWORK_LOCKED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_CORPORATE,
Ci.nsIIcc.CARD_STATE_RUIM_CORPORATE_LOCKED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER,
Ci.nsIIcc.CARD_STATE_RUIM_SERVICE_PROVIDER_LOCKED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_RUIM,
Ci.nsIIcc.CARD_STATE_RUIM_LOCKED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_NETWORK1_PUK,
Ci.nsIIcc.CARD_STATE_NETWORK1_PUK_REQUIRED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_NETWORK2_PUK,
Ci.nsIIcc.CARD_STATE_NETWORK2_PUK_REQUIRED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_HRPD_PUK,
Ci.nsIIcc.CARD_STATE_HRPD_NETWORK_PUK_REQUIRED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_CORPORATE_PUK,
Ci.nsIIcc.CARD_STATE_RUIM_CORPORATE_PUK_REQUIRED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK,
Ci.nsIIcc.CARD_STATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED);
testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_RUIM_PUK,
Ci.nsIIcc.CARD_STATE_RUIM_PUK_REQUIRED);
testPersonalization(true, CARD_PERSOSUBSTATE_UNKNOWN,
Ci.nsIIcc.CARD_STATE_UNKNOWN);
testPersonalization(true, CARD_PERSOSUBSTATE_IN_PROGRESS,
Ci.nsIIcc.CARD_STATE_PERSONALIZATION_IN_PROGRESS);
testPersonalization(true, CARD_PERSOSUBSTATE_READY,
Ci.nsIIcc.CARD_STATE_PERSONALIZATION_READY);
run_next_test();
});
/**
* Verify SIM app_state in _processICCStatus
*/
add_test(function test_card_app_state() {
let worker = newUint8Worker();
let context = worker.ContextPool._contexts[0];
let ril = context.RIL;
context.ICCRecordHelper.readICCID = function fakeReadICCID() {};
function testCardAppState(cardAppState, geckoCardState) {
let iccStatus = {
cardState: CARD_STATE_PRESENT,
gsmUmtsSubscriptionAppIndex: 0,
apps: [
{
app_state: cardAppState
}],
};
ril._processICCStatus(iccStatus);
equal(ril.cardState, geckoCardState);
}
testCardAppState(CARD_APPSTATE_ILLEGAL,
Ci.nsIIcc.CARD_STATE_ILLEGAL);
testCardAppState(CARD_APPSTATE_PIN,
Ci.nsIIcc.CARD_STATE_PIN_REQUIRED);
testCardAppState(CARD_APPSTATE_PUK,
Ci.nsIIcc.CARD_STATE_PUK_REQUIRED);
testCardAppState(CARD_APPSTATE_READY,
Ci.nsIIcc.CARD_STATE_READY);
testCardAppState(CARD_APPSTATE_UNKNOWN,
Ci.nsIIcc.CARD_STATE_UNKNOWN);
testCardAppState(CARD_APPSTATE_DETECTED,
Ci.nsIIcc.CARD_STATE_UNKNOWN);
run_next_test();
});
/**
* Verify permanent blocked for ICC.
*/
add_test(function test_icc_permanent_blocked() {
let worker = newUint8Worker();
let context = worker.ContextPool._contexts[0];
let ril = context.RIL;
context.ICCRecordHelper.readICCID = function fakeReadICCID() {};
function testPermanentBlocked(pin1_replaced, universalPINState, pin1) {
let iccStatus = {
cardState: CARD_STATE_PRESENT,
gsmUmtsSubscriptionAppIndex: 0,
universalPINState: universalPINState,
apps: [
{
pin1_replaced: pin1_replaced,
pin1: pin1
}]
};
ril._processICCStatus(iccStatus);
equal(ril.cardState, Ci.nsIIcc.CARD_STATE_PERMANENT_BLOCKED);
}
testPermanentBlocked(1,
CARD_PINSTATE_ENABLED_PERM_BLOCKED,
CARD_PINSTATE_UNKNOWN);
testPermanentBlocked(1,
CARD_PINSTATE_ENABLED_PERM_BLOCKED,
CARD_PINSTATE_ENABLED_PERM_BLOCKED);
testPermanentBlocked(0,
CARD_PINSTATE_UNKNOWN,
CARD_PINSTATE_ENABLED_PERM_BLOCKED);
run_next_test();
});
/**
* Verify ICC without app index.
*/
add_test(function test_icc_without_app_index() {
const ICCID = "123456789";
let worker = newUint8Worker();
let context = worker.ContextPool._contexts[0];
let ril = context.RIL;
let iccStatus = {
cardState: CARD_STATE_PRESENT,
gsmUmtsSubscriptionAppIndex: -1,
universalPINState: CARD_PINSTATE_DISABLED,
apps: [
{
app_state: CARD_APPSTATE_READY
}]
};
context.ICCRecordHelper.readICCID = function fakeReadICCID() {
ril.iccInfo.iccid = ICCID;
};
ril._processICCStatus(iccStatus);
// Should read icc id event if the app index is -1.
equal(ril.iccInfo.iccid, ICCID);
// cardState is "unknown" if the app index is -1.
equal(ril.cardState, GECKO_CARDSTATE_UNKNOWN);
run_next_test();
});
|