• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 package com.android.internal.telephony;
17 
18 import static com.google.common.truth.Truth.assertThat;
19 
20 import static org.junit.Assert.assertFalse;
21 import static org.junit.Assert.assertTrue;
22 
23 import android.os.Parcel;
24 import android.telephony.AccessNetworkConstants;
25 import android.telephony.SignalThresholdInfo;
26 
27 import androidx.test.filters.SmallTest;
28 
29 import junit.framework.TestCase;
30 
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.junit.runners.JUnit4;
34 
35 import java.util.ArrayList;
36 import java.util.Arrays;
37 import java.util.List;
38 import java.util.Map;
39 import java.util.Set;
40 
41 @RunWith(JUnit4.class)
42 public class SignalThresholdInfoTest extends TestCase {
43     private static final int HYSTERESIS_DB = 2;
44     private static final int HYSTERESIS_MS = 30;
45     private static final int[] SSRSRP_THRESHOLDS = new int[]{-120, -100, -80, -60};
46 
47     // Map of SignalMeasurementType to invalid thresholds edge values.
48     // Each invalid value will be constructed with a thresholds array to test separately.
49     private static final Map<Integer, List<Integer>> INVALID_THRESHOLDS_MAP = Map.of(
50             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI,
51             List.of(SignalThresholdInfo.SIGNAL_RSSI_MIN_VALUE - 1,
52                     SignalThresholdInfo.SIGNAL_RSSI_MAX_VALUE + 1),
53             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSCP,
54             List.of(SignalThresholdInfo.SIGNAL_RSCP_MIN_VALUE - 1,
55                     SignalThresholdInfo.SIGNAL_RSCP_MAX_VALUE + 1),
56             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP,
57             List.of(SignalThresholdInfo.SIGNAL_RSRP_MIN_VALUE - 1,
58                     SignalThresholdInfo.SIGNAL_RSRP_MAX_VALUE + 1),
59             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRQ,
60             List.of(SignalThresholdInfo.SIGNAL_RSRQ_MIN_VALUE - 1,
61                     SignalThresholdInfo.SIGNAL_RSRQ_MAX_VALUE + 1),
62             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSNR,
63             List.of(SignalThresholdInfo.SIGNAL_RSSNR_MIN_VALUE - 1,
64                     SignalThresholdInfo.SIGNAL_RSSNR_MAX_VALUE + 1),
65             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP,
66             List.of(SignalThresholdInfo.SIGNAL_SSRSRP_MIN_VALUE - 1,
67                     SignalThresholdInfo.SIGNAL_SSRSRP_MAX_VALUE + 1),
68             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRQ,
69             List.of(SignalThresholdInfo.SIGNAL_SSRSRQ_MIN_VALUE - 1,
70                     SignalThresholdInfo.SIGNAL_SSRSRQ_MAX_VALUE + 1),
71             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSSINR,
72             List.of(SignalThresholdInfo.SIGNAL_SSSINR_MIN_VALUE - 1,
73                     SignalThresholdInfo.SIGNAL_SSSINR_MAX_VALUE + 1)
74     );
75 
76     // Map of RAN to allowed SignalMeasurementType set.
77     // RAN/TYPE pair will be used to verify the validation of the combo
78     private static final Map<Integer, Set<Integer>> VALID_RAN_TO_MEASUREMENT_TYPE_MAP = Map.of(
79             AccessNetworkConstants.AccessNetworkType.GERAN,
80             Set.of(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI),
81             AccessNetworkConstants.AccessNetworkType.CDMA2000,
82             Set.of(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI),
83             AccessNetworkConstants.AccessNetworkType.UTRAN,
84             Set.of(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSCP),
85             AccessNetworkConstants.AccessNetworkType.EUTRAN,
86             Set.of(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP,
87                     SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRQ,
88                     SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSNR),
89             AccessNetworkConstants.AccessNetworkType.NGRAN,
90             Set.of(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP,
91                     SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRQ,
92                     SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSSINR)
93     );
94 
95     // Deliberately picking up the max/min value in each range to test the edge cases
96     private final int[] mRssiThresholds = new int[]{-113, -103, -97, -51};
97     private final int[] mRscpThresholds = new int[]{-120, -105, -95, -25};
98     private final int[] mRsrpThresholds = new int[]{-140, -118, -108, -44};
99     private final int[] mRsrqThresholds = new int[]{-34, -17, -14, 3};
100     private final int[] mRssnrThresholds = new int[]{-20, 10, 20, 30};
101     private final int[] mSsrsrpThresholds = new int[]{-140, -118, -98, -44};
102     private final int[] mSsrsrqThresholds = new int[]{-43, -17, -14, 20};
103     private final int[] mSssinrThresholds = new int[]{-23, -16, -10, 40};
104 
105     private final int[][] mThresholds = {mRssiThresholds, mRscpThresholds, mRsrpThresholds,
106             mRsrqThresholds, mRssnrThresholds, mSsrsrpThresholds, mSsrsrqThresholds,
107             mSssinrThresholds};
108 
109     @Test
110     @SmallTest
testSignalThresholdInfo()111     public void testSignalThresholdInfo() throws Exception {
112         SignalThresholdInfo signalThresholdInfo =
113                 new SignalThresholdInfo.Builder()
114                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
115                         .setSignalMeasurementType(
116                                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP)
117                         .setHysteresisMs(HYSTERESIS_MS)
118                         .setHysteresisDb(HYSTERESIS_DB)
119                         .setThresholds(SSRSRP_THRESHOLDS)
120                         .setIsEnabled(false)
121                         .build();
122 
123         assertEquals(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP,
124                 signalThresholdInfo.getSignalMeasurementType());
125         assertEquals(HYSTERESIS_MS, signalThresholdInfo.getHysteresisMs());
126         assertEquals(HYSTERESIS_DB, signalThresholdInfo.getHysteresisDb());
127         assertEquals(Arrays.toString(SSRSRP_THRESHOLDS), Arrays.toString(
128                 signalThresholdInfo.getThresholds()));
129         assertFalse(signalThresholdInfo.isEnabled());
130     }
131 
132     @Test
133     @SmallTest
testBuilderWithAllFields()134     public void testBuilderWithAllFields() {
135         ArrayList<SignalThresholdInfo> stList = buildSignalThresholdInfoWithAllFields();
136 
137         int count = 0;
138         for (SignalThresholdInfo st : stList) {
139             assertThat(st.getThresholds()).isEqualTo(mThresholds[count]);
140             count++;
141         }
142     }
143 
144     @Test
145     @SmallTest
testDefaultThresholdsParcel()146     public void testDefaultThresholdsParcel() {
147         ArrayList<SignalThresholdInfo> stList = buildSignalThresholdInfoWithAllFields();
148 
149         for (SignalThresholdInfo st : stList) {
150             Parcel p = Parcel.obtain();
151             st.writeToParcel(p, 0);
152             p.setDataPosition(0);
153 
154             SignalThresholdInfo newSt = SignalThresholdInfo.CREATOR.createFromParcel(p);
155             assertThat(newSt).isEqualTo(st);
156         }
157     }
158 
159     @Test
160     @SmallTest
testGetSignalThresholdInfo()161     public void testGetSignalThresholdInfo() {
162         ArrayList<SignalThresholdInfo> stList = new ArrayList<>();
163         stList.add(new SignalThresholdInfo.Builder()
164                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN)
165                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
166                 .setHysteresisMs(0)
167                 .setHysteresisDb(0)
168                 .setThresholds(new int[]{}, true /*isSystem*/)
169                 .setIsEnabled(false)
170                 .build());
171         stList.add(new SignalThresholdInfo.Builder()
172                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN)
173                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
174                 .setHysteresisMs(HYSTERESIS_MS).setHysteresisDb(HYSTERESIS_DB)
175                 .setThresholds(mRssiThresholds)
176                 .setIsEnabled(false)
177                 .build());
178 
179         assertThat(stList.get(0).getThresholds()).isEqualTo(new int[]{});
180         assertThat(stList.get(1).getSignalMeasurementType()).isEqualTo(
181                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI);
182         assertThat(stList.get(1).getThresholds()).isEqualTo(mRssiThresholds);
183     }
184 
185     @Test
186     @SmallTest
testEqualsSignalThresholdInfo()187     public void testEqualsSignalThresholdInfo() {
188         final int[] dummyThresholds = new int[]{-100, -90, -70, -60};
189         final int[] dummyThreholdsDisordered = new int[]{-60, -90, -100, -70};
190         SignalThresholdInfo st1 = new SignalThresholdInfo.Builder()
191                 .setRadioAccessNetworkType(1).setSignalMeasurementType(1)
192                 .setHysteresisMs(HYSTERESIS_MS).setHysteresisDb(HYSTERESIS_DB)
193                 .setThresholds(mRssiThresholds).setIsEnabled(false)
194                 .build();
195         SignalThresholdInfo st2 = new SignalThresholdInfo.Builder().setRadioAccessNetworkType(2)
196                 .setSignalMeasurementType(2).setHysteresisMs(HYSTERESIS_MS)
197                 .setHysteresisDb(HYSTERESIS_DB).setThresholds(mRssiThresholds).setIsEnabled(false)
198                 .build();
199         SignalThresholdInfo st3 = new SignalThresholdInfo.Builder().setRadioAccessNetworkType(1)
200                 .setSignalMeasurementType(1).setHysteresisMs(HYSTERESIS_MS)
201                 .setHysteresisDb(HYSTERESIS_DB).setThresholds(dummyThresholds).setIsEnabled(false)
202                 .build();
203         SignalThresholdInfo st4 = new SignalThresholdInfo.Builder().setRadioAccessNetworkType(1)
204                 .setSignalMeasurementType(1).setHysteresisMs(HYSTERESIS_MS)
205                 .setHysteresisDb(HYSTERESIS_DB).setThresholds(mRssiThresholds).setIsEnabled(false)
206                 .build();
207         SignalThresholdInfo st5 = new SignalThresholdInfo.Builder().setRadioAccessNetworkType(1)
208                 .setSignalMeasurementType(1).setHysteresisMs(HYSTERESIS_MS)
209                 .setHysteresisDb(HYSTERESIS_DB).setThresholds(dummyThreholdsDisordered)
210                 .setIsEnabled(false).build();
211 
212         //Return true if all SignalThresholdInfo values match.
213         assertTrue(st1.equals(st1));
214         assertFalse(st1.equals(st2));
215         assertFalse(st1.equals(st3));
216         assertTrue(st1.equals(st4));
217         //Threshold values ordering doesn't matter
218         assertTrue(st3.equals(st5));
219         //Return false if the object of argument is other than SignalThresholdInfo.
220         assertFalse(st1.equals(new String("test")));
221     }
222 
223     @Test
224     @SmallTest
testBuilderWithValidParameters()225     public void testBuilderWithValidParameters() {
226         ArrayList<SignalThresholdInfo> stList = buildSignalThresholdInfoWithPublicFields();
227 
228         for (int i = 0; i < stList.size(); i++) {
229             SignalThresholdInfo st = stList.get(i);
230             assertThat(st.getThresholds()).isEqualTo(mThresholds[i]);
231             assertThat(st.getHysteresisMs()).isEqualTo(SignalThresholdInfo.HYSTERESIS_MS_DISABLED);
232             assertThat(st.getHysteresisDb()).isEqualTo(SignalThresholdInfo.HYSTERESIS_DB_DISABLED);
233             assertFalse(st.isEnabled());
234         }
235     }
236 
237     @Test
238     @SmallTest
testBuilderWithInvalidParameter()239     public void testBuilderWithInvalidParameter() {
240         // Invalid signal measurement type
241         int[] invalidSignalMeasurementTypes = new int[]{-1, 0, 9};
242         for (int signalMeasurementType : invalidSignalMeasurementTypes) {
243             buildWithInvalidParameterThrowException(
244                     AccessNetworkConstants.AccessNetworkType.GERAN, signalMeasurementType,
245                     new int[]{-1});
246         }
247 
248         // Null thresholds array
249         buildWithInvalidParameterThrowException(AccessNetworkConstants.AccessNetworkType.GERAN,
250                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI, null);
251 
252         // Empty thresholds
253         buildWithInvalidParameterThrowException(AccessNetworkConstants.AccessNetworkType.GERAN,
254                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI, new int[]{});
255 
256 
257         // Too long thresholds array
258         buildWithInvalidParameterThrowException(AccessNetworkConstants.AccessNetworkType.GERAN,
259                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI,
260                 new int[]{-100, -90, -70, -60, -58});
261 
262         // Thresholds value out of range
263         for (int signalMeasurementType : INVALID_THRESHOLDS_MAP.keySet()) {
264             List<Integer> invalidThresholds = INVALID_THRESHOLDS_MAP.get(signalMeasurementType);
265             for (int threshold : invalidThresholds) {
266                 buildWithInvalidParameterThrowException(getValidRan(signalMeasurementType),
267                         signalMeasurementType, new int[]{threshold});
268             }
269         }
270 
271         // Invalid RAN/Measurement type combos
272         for (int ran : VALID_RAN_TO_MEASUREMENT_TYPE_MAP.keySet()) {
273             Set validTypes = VALID_RAN_TO_MEASUREMENT_TYPE_MAP.get(ran);
274             for (int type = SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI;
275                     type <= SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSSINR; type++) {
276                 if (!validTypes.contains(type)) {
277                     buildWithInvalidParameterThrowException(ran, type, new int[]{-1});
278                 }
279             }
280         }
281     }
282 
buildWithInvalidParameterThrowException(int ran, int signalMeasurementType, int[] thresholds)283     private void buildWithInvalidParameterThrowException(int ran, int signalMeasurementType,
284             int[] thresholds) {
285         try {
286             new SignalThresholdInfo.Builder()
287                     .setRadioAccessNetworkType(ran)
288                     .setSignalMeasurementType(signalMeasurementType)
289                     .setThresholds(thresholds)
290                     .build();
291             fail("exception expected");
292         } catch (IllegalArgumentException | NullPointerException expected) {
293         }
294     }
295 
buildSignalThresholdInfoWithAllFields()296     private ArrayList<SignalThresholdInfo> buildSignalThresholdInfoWithAllFields() {
297         ArrayList<SignalThresholdInfo> stList = new ArrayList<>();
298 
299         stList.add(new SignalThresholdInfo.Builder()
300                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN)
301                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
302                 .setHysteresisMs(HYSTERESIS_MS).setHysteresisDb(HYSTERESIS_DB)
303                 .setThresholds(mRssiThresholds).setIsEnabled(false)
304                 .build());
305         stList.add(new SignalThresholdInfo.Builder()
306                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.UTRAN)
307                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSCP)
308                 .setHysteresisMs(HYSTERESIS_MS)
309                 .setHysteresisDb(HYSTERESIS_DB)
310                 .setThresholds(mRscpThresholds)
311                 .setIsEnabled(false)
312                 .build());
313         stList.add(new SignalThresholdInfo.Builder()
314                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
315                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP)
316                 .setHysteresisMs(HYSTERESIS_MS)
317                 .setHysteresisDb(HYSTERESIS_DB)
318                 .setThresholds(mRsrpThresholds)
319                 .setIsEnabled(false)
320                 .build());
321         stList.add(new SignalThresholdInfo.Builder()
322                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
323                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRQ)
324                 .setHysteresisMs(HYSTERESIS_MS)
325                 .setHysteresisDb(HYSTERESIS_DB)
326                 .setThresholds(mRsrqThresholds)
327                 .setIsEnabled(false)
328                 .build());
329         stList.add(new SignalThresholdInfo.Builder()
330                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
331                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSNR)
332                 .setHysteresisMs(HYSTERESIS_MS)
333                 .setHysteresisDb(HYSTERESIS_DB)
334                 .setThresholds(mRssnrThresholds)
335                 .setIsEnabled(false)
336                 .build());
337         stList.add(new SignalThresholdInfo.Builder()
338                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
339                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP)
340                 .setHysteresisMs(HYSTERESIS_MS)
341                 .setHysteresisDb(HYSTERESIS_DB)
342                 .setThresholds(mSsrsrpThresholds)
343                 .setIsEnabled(false)
344                 .build());
345         stList.add(new SignalThresholdInfo.Builder()
346                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
347                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRQ)
348                 .setHysteresisMs(HYSTERESIS_MS)
349                 .setHysteresisDb(HYSTERESIS_DB)
350                 .setThresholds(mSsrsrqThresholds)
351                 .setIsEnabled(false)
352                 .build());
353         stList.add(new SignalThresholdInfo.Builder()
354                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
355                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSSINR)
356                 .setHysteresisMs(HYSTERESIS_MS)
357                 .setHysteresisDb(HYSTERESIS_DB)
358                 .setThresholds(mSssinrThresholds)
359                 .setIsEnabled(false)
360                 .build());
361 
362         return stList;
363     }
364 
buildSignalThresholdInfoWithPublicFields()365     private ArrayList<SignalThresholdInfo> buildSignalThresholdInfoWithPublicFields() {
366         ArrayList<SignalThresholdInfo> stList = new ArrayList<>();
367 
368         stList.add(new SignalThresholdInfo.Builder()
369                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN)
370                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
371                 .setThresholds(mRssiThresholds)
372                 .build());
373         stList.add(new SignalThresholdInfo.Builder()
374                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.UTRAN)
375                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSCP)
376                 .setThresholds(mRscpThresholds)
377                 .build());
378         stList.add(new SignalThresholdInfo.Builder()
379                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
380                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP)
381                 .setThresholds(mRsrpThresholds)
382                 .build());
383         stList.add(new SignalThresholdInfo.Builder()
384                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
385                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRQ)
386                 .setThresholds(mRsrqThresholds)
387                 .build());
388         stList.add(new SignalThresholdInfo.Builder()
389                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
390                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSNR)
391                 .setThresholds(mRssnrThresholds)
392                 .build());
393         stList.add(new SignalThresholdInfo.Builder()
394                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
395                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP)
396                 .setThresholds(mSsrsrpThresholds)
397                 .build());
398         stList.add(new SignalThresholdInfo.Builder()
399                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
400                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRQ)
401                 .setThresholds(mSsrsrqThresholds)
402                 .build());
403         stList.add(new SignalThresholdInfo.Builder()
404                 .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
405                 .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSSINR)
406                 .setThresholds(mSssinrThresholds)
407                 .build());
408 
409         return stList;
410     }
411 
412     /**
413      * Return a possible valid RAN value for the measurement type. This is used to prevent the
414      * invalid ran/type causing IllegalArgumentException when testing other invalid input cases.
415      */
getValidRan(@ignalThresholdInfo.SignalMeasurementType int type)416     private static int getValidRan(@SignalThresholdInfo.SignalMeasurementType int type) {
417         switch (type) {
418             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI:
419                 return AccessNetworkConstants.AccessNetworkType.GERAN;
420             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSCP:
421                 return AccessNetworkConstants.AccessNetworkType.UTRAN;
422             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP:
423             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRQ:
424             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSNR:
425                 return AccessNetworkConstants.AccessNetworkType.EUTRAN;
426             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP:
427             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRQ:
428             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSSINR:
429                 return AccessNetworkConstants.AccessNetworkType.NGRAN;
430             default:
431                 return AccessNetworkConstants.AccessNetworkType.UNKNOWN;
432         }
433     }
434 }
435