• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3#   Copyright 2016 - The Android Open Source Project
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"""
17Tests for reading UE Identity
18"""
19import time
20from acts.controllers.anritsu_lib._anritsu_utils import AnritsuError
21from acts.controllers.anritsu_lib.md8475a import MD8475A
22from acts.controllers.anritsu_lib.md8475a import UEIdentityType
23from acts.test_utils.tel.anritsu_utils import WAIT_TIME_ANRITSU_REG_AND_OPER
24from acts.test_utils.tel.anritsu_utils import read_ue_identity
25from acts.test_utils.tel.anritsu_utils import set_system_model_gsm
26from acts.test_utils.tel.anritsu_utils import set_system_model_lte
27from acts.test_utils.tel.anritsu_utils import set_system_model_wcdma
28from acts.test_utils.tel.tel_defines import NETWORK_MODE_CDMA
29from acts.test_utils.tel.tel_defines import NETWORK_MODE_GSM_ONLY
30from acts.test_utils.tel.tel_defines import NETWORK_MODE_GSM_UMTS
31from acts.test_utils.tel.tel_defines import NETWORK_MODE_LTE_GSM_WCDMA
32from acts.test_utils.tel.tel_defines import RAT_1XRTT
33from acts.test_utils.tel.tel_defines import RAT_GSM
34from acts.test_utils.tel.tel_defines import RAT_LTE
35from acts.test_utils.tel.tel_defines import RAT_WCDMA
36from acts.test_utils.tel.tel_defines import RAT_FAMILY_CDMA2000
37from acts.test_utils.tel.tel_defines import RAT_FAMILY_GSM
38from acts.test_utils.tel.tel_defines import RAT_FAMILY_LTE
39from acts.test_utils.tel.tel_defines import RAT_FAMILY_UMTS
40from acts.test_utils.tel.tel_test_utils import ensure_network_rat
41from acts.test_utils.tel.tel_test_utils import ensure_phones_idle
42from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode
43from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
44
45
46class TelLabUeIdentityTest(TelephonyBaseTest):
47
48    CELL_PARAM_FILE = 'C:\\MX847570\\CellParam\\ACTS\\2cell_param.wnscp'
49
50    def __init__(self, controllers):
51        TelephonyBaseTest.__init__(self, controllers)
52        self.ad = self.android_devices[0]
53        self.md8475a_ip_address = self.user_params[
54            "anritsu_md8475a_ip_address"]
55        self.ad.sim_card = getattr(self.ad, "sim_card", None)
56
57    def setup_class(self):
58        try:
59            self.anritsu = MD8475A(self.md8475a_ip_address, self.log)
60        except AnritsuError:
61            self.log.error("Error in connecting to Anritsu Simulator")
62            return False
63        return True
64
65    def setup_test(self):
66        ensure_phones_idle(self.log, self.android_devices)
67        toggle_airplane_mode(self.log, self.ad, True)
68        self.ad.adb.shell("setprop net.lte.ims.volte.provisioned 1",
69                          ignore_status=True)
70        return True
71
72    def teardown_test(self):
73        self.log.info("Stopping Simulation")
74        self.anritsu.stop_simulation()
75        toggle_airplane_mode(self.log, self.ad, True)
76        return True
77
78    def teardown_class(self):
79        self.anritsu.disconnect()
80        return True
81
82    def _read_identity(self, set_simulation_func, rat, identity_type):
83        try:
84            self.anritsu.reset()
85            self.anritsu.load_cell_paramfile(self.CELL_PARAM_FILE)
86            set_simulation_func(self.anritsu, self.user_params,
87                                self.ad.sim_card)
88            self.anritsu.start_simulation()
89
90            if rat == RAT_LTE:
91                preferred_network_setting = NETWORK_MODE_LTE_GSM_WCDMA
92                rat_family = RAT_FAMILY_LTE
93            elif rat == RAT_WCDMA:
94                preferred_network_setting = NETWORK_MODE_GSM_UMTS
95                rat_family = RAT_FAMILY_UMTS
96            elif rat == RAT_GSM:
97                preferred_network_setting = NETWORK_MODE_GSM_ONLY
98                rat_family = RAT_FAMILY_GSM
99            elif rat == RAT_1XRTT:
100                preferred_network_setting = NETWORK_MODE_CDMA
101                rat_family = RAT_FAMILY_CDMA2000
102            else:
103                self.log.error("Invalid RAT - Please specify a valid RAT")
104                return False
105
106            self.ad.droid.telephonyToggleDataConnection(True)
107            if not ensure_network_rat(
108                    self.log,
109                    self.ad,
110                    preferred_network_setting,
111                    rat_family,
112                    toggle_apm_after_setting=True):
113                self.log.error(
114                    "Failed to set rat family {}, preferred network:{}".format(
115                        rat_family, preferred_network_setting))
116                return False
117            self.anritsu.wait_for_registration_state()
118            time.sleep(WAIT_TIME_ANRITSU_REG_AND_OPER)
119            identity = read_ue_identity(self.log, self.ad, self.anritsu,
120                                        identity_type)
121            if identity is None:
122                self.log.error("Phone {} Failed to get {}"
123                               .format(self.ad.serial, identity_type.value))
124                return False
125            else:
126                self.log.info("{}".format(identity))
127        except AnritsuError as e:
128            self.log.error("Error in connection with Anritsu Simulator: " +
129                           str(e))
130            return False
131        except Exception as e:
132            self.log.error("Exception during reading identity: " + str(e))
133            return False
134        return True
135
136    """ Tests Begin """
137
138    @TelephonyBaseTest.tel_test_wrap
139    def test_read_imsi_lte(self):
140        """Reading the IMSI of UE on LTE
141
142        Reads the IMSI of the UE when device is camped on LTE newtork
143
144        Steps:
145        1. Make Sure Phone is camped on LTE network
146        2. Send IMSI request from Anritsu
147        3. Display the IMSI returned by UE
148
149        Expected Result:
150        UE sends the correct IMSI to the Anritsu
151
152        Returns:
153            True if pass; False if fail
154        """
155        return self._read_identity(set_system_model_lte, RAT_LTE,
156                                   UEIdentityType.IMSI)
157
158    @TelephonyBaseTest.tel_test_wrap
159    def test_read_imei_lte(self):
160        """Reading the IMEI of UE on LTE
161
162        Reads the IMEI of the UE when device is camped on LTE newtork
163
164        Steps:
165        1. Make Sure Phone is camped on LTE network
166        2. Send IMEI request from Anritsu
167        3. Display the IMEI returned by UE
168
169        Expected Result:
170        UE sends the correct IMEI to the Anritsu
171
172        Returns:
173            True if pass; False if fail
174        """
175        return self._read_identity(set_system_model_lte, RAT_LTE,
176                                   UEIdentityType.IMEI)
177
178    @TelephonyBaseTest.tel_test_wrap
179    def test_read_imeisv_lte(self):
180        """Reading the IMEISV of UE on LTE
181
182        Reads the IMEISV of the UE when device is camped on LTE newtork
183
184        Steps:
185        1. Make Sure Phone is camped on LTE network
186        2. Send IMEISV request from Anritsu
187        3. Display the IMEISV returned by UE
188
189        Expected Result:
190        UE sends the correct IMEISV to the Anritsu
191
192        Returns:
193            True if pass; False if fail
194        """
195        return self._read_identity(set_system_model_lte, RAT_LTE,
196                                   UEIdentityType.IMEISV)
197
198    @TelephonyBaseTest.tel_test_wrap
199    def test_read_imsi_wcdma(self):
200        """Reading the IMSI of UE on WCDMA
201
202        Reads the IMSI of the UE when device is camped on WCDMA newtork
203
204        Steps:
205        1. Make Sure Phone is camped on WCDMA network
206        2. Send IMSI request from Anritsu
207        3. Display the IMSI returned by UE
208
209        Expected Result:
210        UE sends the correct IMSI to the Anritsu
211
212        Returns:
213            True if pass; False if fail
214        """
215        return self._read_identity(set_system_model_wcdma, RAT_WCDMA,
216                                   UEIdentityType.IMSI)
217
218    @TelephonyBaseTest.tel_test_wrap
219    def test_read_imei_wcdma(self):
220        """Reading the IMEI of UE on WCDMA
221
222        Reads the IMEI of the UE when device is camped on WCDMA newtork
223
224        Steps:
225        1. Make Sure Phone is camped on WCDMA network
226        2. Send IMEI request from Anritsu
227        3. Display the IMEI returned by UE
228
229        Expected Result:
230        UE sends the correct IMEI to the Anritsu
231
232        Returns:
233            True if pass; False if fail
234        """
235        return self._read_identity(set_system_model_wcdma, RAT_WCDMA,
236                                   UEIdentityType.IMEI)
237
238    @TelephonyBaseTest.tel_test_wrap
239    def test_read_imeisv_wcdma(self):
240        """Reading the IMEISV of UE on WCDMA
241
242        Reads the IMEISV of the UE when device is camped on WCDMA newtork
243
244        Steps:
245        1. Make Sure Phone is camped on WCDMA network
246        2. Send IMEISV request from Anritsu
247        3. Display the IMEISV returned by UE
248
249        Expected Result:
250        UE sends the correct IMEISV to the Anritsu
251
252        Returns:
253            True if pass; False if fail
254        """
255        return self._read_identity(set_system_model_wcdma, RAT_WCDMA,
256                                   UEIdentityType.IMEISV)
257
258    @TelephonyBaseTest.tel_test_wrap
259    def test_read_imsi_gsm(self):
260        """Reading the IMSI of UE on GSM
261
262        Reads the IMSI of the UE when device is camped on GSM newtork
263
264        Steps:
265        1. Make Sure Phone is camped on GSM network
266        2. Send IMSI request from Anritsu
267        3. Display the IMSI returned by UE
268
269        Expected Result:
270        UE sends the correct IMSI to the Anritsu
271
272        Returns:
273            True if pass; False if fail
274        """
275        return self._read_identity(set_system_model_gsm, RAT_GSM,
276                                   UEIdentityType.IMSI)
277
278    @TelephonyBaseTest.tel_test_wrap
279    def test_read_imei_gsm(self):
280        """Reading the IMEI of UE on GSM
281
282        Reads the IMEI of the UE when device is camped on GSM newtork
283
284        Steps:
285        1. Make Sure Phone is camped on GSM network
286        2. Send IMEI request from Anritsu
287        3. Display the IMEI returned by UE
288
289        Expected Result:
290        UE sends the correct IMEI to the Anritsu
291
292        Returns:
293            True if pass; False if fail
294        """
295        return self._read_identity(set_system_model_gsm, RAT_GSM,
296                                   UEIdentityType.IMEI)
297
298    @TelephonyBaseTest.tel_test_wrap
299    def test_read_imeisv_gsm(self):
300        """Reading the IMEISV of UE on GSM
301
302        Reads the IMEISV of the UE when device is camped on GSM newtork
303
304        Steps:
305        1. Make Sure Phone is camped on GSM network
306        2. Send IMEISV request from Anritsu
307        3. Display the IMEISV returned by UE
308
309        Expected Result:
310        UE sends the correct IMEISV to the Anritsu
311
312        Returns:
313            True if pass; False if fail
314        """
315        return self._read_identity(set_system_model_gsm, RAT_GSM,
316                                   UEIdentityType.IMEISV)
317
318    """ Tests End """
319