• 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 =
50             Map.of(
51                     SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI,
52                     List.of(
53                             SignalThresholdInfo.SIGNAL_RSSI_MIN_VALUE - 1,
54                             SignalThresholdInfo.SIGNAL_RSSI_MAX_VALUE + 1),
55                     SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSCP,
56                     List.of(
57                             SignalThresholdInfo.SIGNAL_RSCP_MIN_VALUE - 1,
58                             SignalThresholdInfo.SIGNAL_RSCP_MAX_VALUE + 1),
59                     SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP,
60                     List.of(
61                             SignalThresholdInfo.SIGNAL_RSRP_MIN_VALUE - 1,
62                             SignalThresholdInfo.SIGNAL_RSRP_MAX_VALUE + 1),
63                     SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRQ,
64                     List.of(
65                             SignalThresholdInfo.SIGNAL_RSRQ_MIN_VALUE - 1,
66                             SignalThresholdInfo.SIGNAL_RSRQ_MAX_VALUE + 1),
67                     SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSNR,
68                     List.of(
69                             SignalThresholdInfo.SIGNAL_RSSNR_MIN_VALUE - 1,
70                             SignalThresholdInfo.SIGNAL_RSSNR_MAX_VALUE + 1),
71                     SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP,
72                     List.of(
73                             SignalThresholdInfo.SIGNAL_SSRSRP_MIN_VALUE - 1,
74                             SignalThresholdInfo.SIGNAL_SSRSRP_MAX_VALUE + 1),
75                     SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRQ,
76                     List.of(
77                             SignalThresholdInfo.SIGNAL_SSRSRQ_MIN_VALUE - 1,
78                             SignalThresholdInfo.SIGNAL_SSRSRQ_MAX_VALUE + 1),
79                     SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSSINR,
80                     List.of(
81                             SignalThresholdInfo.SIGNAL_SSSINR_MIN_VALUE - 1,
82                             SignalThresholdInfo.SIGNAL_SSSINR_MAX_VALUE + 1),
83                     SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_ECNO,
84                     List.of(
85                             SignalThresholdInfo.SIGNAL_ECNO_MIN_VALUE - 1,
86                             SignalThresholdInfo.SIGNAL_ECNO_MAX_VALUE + 1));
87 
88     // Map of RAN to allowed SignalMeasurementType set.
89     // RAN/TYPE pair will be used to verify the validation of the combo
90     private static final Map<Integer, Set<Integer>> VALID_RAN_TO_MEASUREMENT_TYPE_MAP =
91             Map.of(
92                     AccessNetworkConstants.AccessNetworkType.GERAN,
93                     Set.of(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI),
94                     AccessNetworkConstants.AccessNetworkType.CDMA2000,
95                     Set.of(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI),
96                     AccessNetworkConstants.AccessNetworkType.UTRAN,
97                     Set.of(
98                             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSCP,
99                             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_ECNO),
100                     AccessNetworkConstants.AccessNetworkType.EUTRAN,
101                     Set.of(
102                             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP,
103                             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRQ,
104                             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSNR),
105                     AccessNetworkConstants.AccessNetworkType.NGRAN,
106                     Set.of(
107                             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP,
108                             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRQ,
109                             SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSSINR));
110 
111     // Deliberately picking up the max/min value in each range to test the edge cases
112     private final int[] mRssiThresholds = new int[] {-113, -103, -97, -51};
113     private final int[] mRscpThresholds = new int[] {-120, -105, -95, -25};
114     private final int[] mRsrpThresholds = new int[] {-140, -118, -108, -44};
115     private final int[] mRsrqThresholds = new int[] {-34, -17, -14, 3};
116     private final int[] mRssnrThresholds = new int[] {-20, 10, 20, 30};
117     private final int[] mSsrsrpThresholds = new int[] {-140, -118, -98, -44};
118     private final int[] mSsrsrqThresholds = new int[] {-43, -17, -14, 20};
119     private final int[] mSssinrThresholds = new int[] {-23, -16, -10, 40};
120     private final int[] mEcnoThresholds = new int[] {-24, -16, -8, 1};
121 
122     private final int[][] mThresholds = {
123         mRssiThresholds,
124         mRscpThresholds,
125         mRsrpThresholds,
126         mRsrqThresholds,
127         mRssnrThresholds,
128         mSsrsrpThresholds,
129         mSsrsrqThresholds,
130         mSssinrThresholds,
131         mEcnoThresholds
132     };
133 
134     @Test
135     @SmallTest
testSignalThresholdInfo()136     public void testSignalThresholdInfo() throws Exception {
137         SignalThresholdInfo signalThresholdInfo =
138                 new SignalThresholdInfo.Builder()
139                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
140                         .setSignalMeasurementType(
141                                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP)
142                         .setHysteresisMs(HYSTERESIS_MS)
143                         .setHysteresisDb(HYSTERESIS_DB)
144                         .setThresholds(SSRSRP_THRESHOLDS)
145                         .setIsEnabled(false)
146                         .build();
147 
148         assertEquals(
149                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP,
150                 signalThresholdInfo.getSignalMeasurementType());
151         assertEquals(HYSTERESIS_MS, signalThresholdInfo.getHysteresisMs());
152         assertEquals(HYSTERESIS_DB, signalThresholdInfo.getHysteresisDb());
153         assertEquals(
154                 Arrays.toString(SSRSRP_THRESHOLDS),
155                 Arrays.toString(signalThresholdInfo.getThresholds()));
156         assertFalse(signalThresholdInfo.isEnabled());
157     }
158 
159     @Test
160     @SmallTest
testBuilderWithAllFields()161     public void testBuilderWithAllFields() {
162         ArrayList<SignalThresholdInfo> stList = buildSignalThresholdInfoWithAllFields();
163 
164         int count = 0;
165         for (SignalThresholdInfo st : stList) {
166             assertThat(st.getThresholds()).isEqualTo(mThresholds[count]);
167             count++;
168         }
169     }
170 
171     @Test
172     @SmallTest
testDefaultThresholdsParcel()173     public void testDefaultThresholdsParcel() {
174         ArrayList<SignalThresholdInfo> stList = buildSignalThresholdInfoWithAllFields();
175 
176         for (SignalThresholdInfo st : stList) {
177             Parcel p = Parcel.obtain();
178             st.writeToParcel(p, 0);
179             p.setDataPosition(0);
180 
181             SignalThresholdInfo newSt = SignalThresholdInfo.CREATOR.createFromParcel(p);
182             assertThat(newSt).isEqualTo(st);
183         }
184     }
185 
186     @Test
187     @SmallTest
testGetSignalThresholdInfo()188     public void testGetSignalThresholdInfo() {
189         ArrayList<SignalThresholdInfo> stList = new ArrayList<>();
190         stList.add(
191                 new SignalThresholdInfo.Builder()
192                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN)
193                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
194                         .setHysteresisMs(0)
195                         .setHysteresisDb(0)
196                         .setThresholds(new int[] {}, true /*isSystem*/)
197                         .setIsEnabled(false)
198                         .build());
199         stList.add(
200                 new SignalThresholdInfo.Builder()
201                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN)
202                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
203                         .setHysteresisMs(HYSTERESIS_MS)
204                         .setHysteresisDb(HYSTERESIS_DB)
205                         .setThresholds(mRssiThresholds)
206                         .setIsEnabled(false)
207                         .build());
208 
209         assertThat(stList.get(0).getThresholds()).isEqualTo(new int[] {});
210         assertThat(stList.get(1).getSignalMeasurementType())
211                 .isEqualTo(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI);
212         assertThat(stList.get(1).getThresholds()).isEqualTo(mRssiThresholds);
213         assertThat(stList.get(0).getHysteresisDb())
214                 .isEqualTo(SignalThresholdInfo.HYSTERESIS_DB_MINIMUM);
215         assertThat(stList.get(1).getHysteresisDb())
216                 .isEqualTo(HYSTERESIS_DB);
217     }
218 
219     @Test
220     @SmallTest
testEqualsSignalThresholdInfo()221     public void testEqualsSignalThresholdInfo() {
222         final int[] dummyThresholds = new int[] {-100, -90, -70, -60};
223         final int[] dummyThresholdsDisordered = new int[] {-60, -90, -100, -70};
224         SignalThresholdInfo st1 =
225                 new SignalThresholdInfo.Builder()
226                         .setRadioAccessNetworkType(1)
227                         .setSignalMeasurementType(1)
228                         .setHysteresisMs(HYSTERESIS_MS)
229                         .setHysteresisDb(HYSTERESIS_DB)
230                         .setThresholds(mRssiThresholds)
231                         .setIsEnabled(false)
232                         .build();
233         SignalThresholdInfo st2 =
234                 new SignalThresholdInfo.Builder()
235                         .setRadioAccessNetworkType(2)
236                         .setSignalMeasurementType(2)
237                         .setHysteresisMs(HYSTERESIS_MS)
238                         .setHysteresisDb(HYSTERESIS_DB)
239                         .setThresholds(mRssiThresholds)
240                         .setIsEnabled(false)
241                         .build();
242         SignalThresholdInfo st3 =
243                 new SignalThresholdInfo.Builder()
244                         .setRadioAccessNetworkType(1)
245                         .setSignalMeasurementType(1)
246                         .setHysteresisMs(HYSTERESIS_MS)
247                         .setHysteresisDb(HYSTERESIS_DB)
248                         .setThresholds(dummyThresholds)
249                         .setIsEnabled(false)
250                         .build();
251         SignalThresholdInfo st4 =
252                 new SignalThresholdInfo.Builder()
253                         .setRadioAccessNetworkType(1)
254                         .setSignalMeasurementType(1)
255                         .setHysteresisMs(HYSTERESIS_MS)
256                         .setHysteresisDb(HYSTERESIS_DB)
257                         .setThresholds(mRssiThresholds)
258                         .setIsEnabled(false)
259                         .build();
260         SignalThresholdInfo st5 =
261                 new SignalThresholdInfo.Builder()
262                         .setRadioAccessNetworkType(1)
263                         .setSignalMeasurementType(1)
264                         .setHysteresisMs(HYSTERESIS_MS)
265                         .setHysteresisDb(HYSTERESIS_DB)
266                         .setThresholds(dummyThresholdsDisordered)
267                         .setIsEnabled(false)
268                         .build();
269 
270         // Return true if all SignalThresholdInfo values match.
271         assertTrue(st1.equals(st1));
272         assertFalse(st1.equals(st2));
273         assertFalse(st1.equals(st3));
274         assertTrue(st1.equals(st4));
275         // Threshold values ordering doesn't matter
276         assertTrue(st3.equals(st5));
277         // Return false if the object of argument is other than SignalThresholdInfo.
278         assertFalse(st1.equals(new String("test")));
279     }
280 
281     @Test
282     @SmallTest
testHysteresisDbSettings_WithValidRange()283     public void testHysteresisDbSettings_WithValidRange() {
284         SignalThresholdInfo st1 =
285                 new SignalThresholdInfo.Builder()
286                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN)
287                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
288                         .setThresholds(new int[] {}, true)
289                         .build();
290         SignalThresholdInfo st2 =
291                 new SignalThresholdInfo.Builder()
292                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN)
293                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
294                         .setThresholds(new int[] {}, true)
295                         .setHysteresisDb(3)
296                         .build();
297         SignalThresholdInfo st3 =
298                 new SignalThresholdInfo.Builder()
299                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN)
300                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
301                         .setThresholds(new int[] {}, true)
302                         .setHysteresisDb(1)
303                         .build();
304         assertThat(st1.getHysteresisDb()).isEqualTo(HYSTERESIS_DB);
305         assertThat(st2.getHysteresisDb()).isEqualTo(3);
306         assertThat(st3.getHysteresisDb()).isEqualTo(1);
307     }
308 
309     @Test
310     @SmallTest
testBuilderWithValidParameters()311     public void testBuilderWithValidParameters() {
312         ArrayList<SignalThresholdInfo> stList = buildSignalThresholdInfoWithPublicFields();
313 
314         for (int i = 0; i < stList.size(); i++) {
315             SignalThresholdInfo st = stList.get(i);
316             assertThat(st.getThresholds()).isEqualTo(mThresholds[i]);
317             assertThat(st.getHysteresisMs()).isEqualTo(SignalThresholdInfo.HYSTERESIS_MS_DISABLED);
318             assertThat(st.getHysteresisDb()).isEqualTo(HYSTERESIS_DB);
319             assertFalse(st.isEnabled());
320         }
321     }
322 
323     @Test
324     @SmallTest
testBuilderWithInvalidParameter()325     public void testBuilderWithInvalidParameter() {
326         // Invalid signal measurement type
327         int[] invalidSignalMeasurementTypes = new int[] {-1, 0, 9};
328         for (int signalMeasurementType : invalidSignalMeasurementTypes) {
329             buildWithInvalidParameterThrowException(
330                     AccessNetworkConstants.AccessNetworkType.GERAN,
331                     signalMeasurementType,
332                     new int[] {-1}, 2);
333         }
334 
335         // Null thresholds array
336         buildWithInvalidParameterThrowException(
337                 AccessNetworkConstants.AccessNetworkType.GERAN,
338                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI,
339                 null, 0);
340 
341         // Empty thresholds
342         buildWithInvalidParameterThrowException(
343                 AccessNetworkConstants.AccessNetworkType.GERAN,
344                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI,
345                 new int[] {}, 5);
346 
347         // Too long thresholds array
348         buildWithInvalidParameterThrowException(
349                 AccessNetworkConstants.AccessNetworkType.GERAN,
350                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI,
351                 new int[] {-100, -90, -70, -60, -58}, 3);
352 
353         // Test Hysteresis Db invalid Range
354         buildWithInvalidParameterThrowException(
355                 AccessNetworkConstants.AccessNetworkType.GERAN,
356                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI,
357                 new int[] {-100, -90, -70, -60}, -1);
358 
359         // Thresholds value out of range
360         for (int signalMeasurementType : INVALID_THRESHOLDS_MAP.keySet()) {
361             List<Integer> invalidThresholds = INVALID_THRESHOLDS_MAP.get(signalMeasurementType);
362             for (int threshold : invalidThresholds) {
363                 buildWithInvalidParameterThrowException(
364                         getValidRan(signalMeasurementType),
365                         signalMeasurementType,
366                         new int[] {threshold}, 1);
367             }
368         }
369 
370         // Invalid RAN/Measurement type combos
371         for (int ran : VALID_RAN_TO_MEASUREMENT_TYPE_MAP.keySet()) {
372             Set validTypes = VALID_RAN_TO_MEASUREMENT_TYPE_MAP.get(ran);
373             for (int type = SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI;
374                     type <= SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_ECNO;
375                     type++) {
376                 if (!validTypes.contains(type)) {
377                     buildWithInvalidParameterThrowException(ran, type, new int[] {-1}, 2);
378                 }
379             }
380         }
381     }
382 
buildWithInvalidParameterThrowException( int ran, int signalMeasurementType, int[] thresholds, int hysteresisDb)383     private void buildWithInvalidParameterThrowException(
384             int ran, int signalMeasurementType, int[] thresholds, int hysteresisDb) {
385         try {
386             new SignalThresholdInfo.Builder()
387                     .setRadioAccessNetworkType(ran)
388                     .setSignalMeasurementType(signalMeasurementType)
389                     .setThresholds(thresholds)
390                     .setHysteresisDb(hysteresisDb)
391                     .build();
392             fail("exception expected");
393         } catch (IllegalArgumentException | NullPointerException expected) {
394         }
395     }
396 
buildSignalThresholdInfoWithAllFields()397     private ArrayList<SignalThresholdInfo> buildSignalThresholdInfoWithAllFields() {
398         ArrayList<SignalThresholdInfo> stList = new ArrayList<>();
399 
400         stList.add(
401                 new SignalThresholdInfo.Builder()
402                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN)
403                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
404                         .setHysteresisMs(HYSTERESIS_MS)
405                         .setHysteresisDb(HYSTERESIS_DB)
406                         .setThresholds(mRssiThresholds)
407                         .setIsEnabled(false)
408                         .build());
409         stList.add(
410                 new SignalThresholdInfo.Builder()
411                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.UTRAN)
412                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSCP)
413                         .setHysteresisMs(HYSTERESIS_MS)
414                         .setHysteresisDb(HYSTERESIS_DB)
415                         .setThresholds(mRscpThresholds)
416                         .setIsEnabled(false)
417                         .build());
418         stList.add(
419                 new SignalThresholdInfo.Builder()
420                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
421                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP)
422                         .setHysteresisMs(HYSTERESIS_MS)
423                         .setHysteresisDb(HYSTERESIS_DB)
424                         .setThresholds(mRsrpThresholds)
425                         .setIsEnabled(false)
426                         .build());
427         stList.add(
428                 new SignalThresholdInfo.Builder()
429                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
430                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRQ)
431                         .setHysteresisMs(HYSTERESIS_MS)
432                         .setHysteresisDb(HYSTERESIS_DB)
433                         .setThresholds(mRsrqThresholds)
434                         .setIsEnabled(false)
435                         .build());
436         stList.add(
437                 new SignalThresholdInfo.Builder()
438                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
439                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSNR)
440                         .setHysteresisMs(HYSTERESIS_MS)
441                         .setHysteresisDb(HYSTERESIS_DB)
442                         .setThresholds(mRssnrThresholds)
443                         .setIsEnabled(false)
444                         .build());
445         stList.add(
446                 new SignalThresholdInfo.Builder()
447                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
448                         .setSignalMeasurementType(
449                                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP)
450                         .setHysteresisMs(HYSTERESIS_MS)
451                         .setHysteresisDb(HYSTERESIS_DB)
452                         .setThresholds(mSsrsrpThresholds)
453                         .setIsEnabled(false)
454                         .build());
455         stList.add(
456                 new SignalThresholdInfo.Builder()
457                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
458                         .setSignalMeasurementType(
459                                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRQ)
460                         .setHysteresisMs(HYSTERESIS_MS)
461                         .setHysteresisDb(HYSTERESIS_DB)
462                         .setThresholds(mSsrsrqThresholds)
463                         .setIsEnabled(false)
464                         .build());
465         stList.add(
466                 new SignalThresholdInfo.Builder()
467                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
468                         .setSignalMeasurementType(
469                                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSSINR)
470                         .setHysteresisMs(HYSTERESIS_MS)
471                         .setHysteresisDb(HYSTERESIS_DB)
472                         .setThresholds(mSssinrThresholds)
473                         .setIsEnabled(false)
474                         .build());
475         stList.add(
476                 new SignalThresholdInfo.Builder()
477                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.UTRAN)
478                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_ECNO)
479                         .setHysteresisMs(HYSTERESIS_MS)
480                         .setHysteresisDb(HYSTERESIS_DB)
481                         .setThresholds(mEcnoThresholds)
482                         .setIsEnabled(false)
483                         .build());
484 
485         return stList;
486     }
487 
buildSignalThresholdInfoWithPublicFields()488     private ArrayList<SignalThresholdInfo> buildSignalThresholdInfoWithPublicFields() {
489         ArrayList<SignalThresholdInfo> stList = new ArrayList<>();
490 
491         stList.add(
492                 new SignalThresholdInfo.Builder()
493                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN)
494                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
495                         .setThresholds(mRssiThresholds)
496                         .build());
497         stList.add(
498                 new SignalThresholdInfo.Builder()
499                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.UTRAN)
500                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSCP)
501                         .setThresholds(mRscpThresholds)
502                         .build());
503         stList.add(
504                 new SignalThresholdInfo.Builder()
505                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
506                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP)
507                         .setThresholds(mRsrpThresholds)
508                         .build());
509         stList.add(
510                 new SignalThresholdInfo.Builder()
511                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
512                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRQ)
513                         .setThresholds(mRsrqThresholds)
514                         .build());
515         stList.add(
516                 new SignalThresholdInfo.Builder()
517                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
518                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSNR)
519                         .setThresholds(mRssnrThresholds)
520                         .build());
521         stList.add(
522                 new SignalThresholdInfo.Builder()
523                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
524                         .setSignalMeasurementType(
525                                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP)
526                         .setThresholds(mSsrsrpThresholds)
527                         .build());
528         stList.add(
529                 new SignalThresholdInfo.Builder()
530                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
531                         .setSignalMeasurementType(
532                                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRQ)
533                         .setThresholds(mSsrsrqThresholds)
534                         .build());
535         stList.add(
536                 new SignalThresholdInfo.Builder()
537                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.NGRAN)
538                         .setSignalMeasurementType(
539                                 SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSSINR)
540                         .setThresholds(mSssinrThresholds)
541                         .build());
542         stList.add(
543                 new SignalThresholdInfo.Builder()
544                         .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.UTRAN)
545                         .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_ECNO)
546                         .setThresholds(mEcnoThresholds)
547                         .build());
548 
549         return stList;
550     }
551 
552     /**
553      * Return a possible valid RAN value for the measurement type. This is used to prevent the
554      * invalid ran/type causing IllegalArgumentException when testing other invalid input cases.
555      */
getValidRan(@ignalThresholdInfo.SignalMeasurementType int type)556     private static int getValidRan(@SignalThresholdInfo.SignalMeasurementType int type) {
557         switch (type) {
558             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI:
559                 return AccessNetworkConstants.AccessNetworkType.GERAN;
560             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSCP:
561             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_ECNO:
562                 return AccessNetworkConstants.AccessNetworkType.UTRAN;
563             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP:
564             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRQ:
565             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSNR:
566                 return AccessNetworkConstants.AccessNetworkType.EUTRAN;
567             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRP:
568             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSRSRQ:
569             case SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_SSSINR:
570                 return AccessNetworkConstants.AccessNetworkType.NGRAN;
571             default:
572                 return AccessNetworkConstants.AccessNetworkType.UNKNOWN;
573         }
574     }
575 }
576