1 /*
2  * Copyright (C) 2016 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.server.telecom.tests;
18 
19 import static android.provider.CallLog.Calls.MISSED_REASON_NOT_MISSED;
20 import static android.provider.CallLog.Calls.USER_MISSED_CALL_FILTERS_TIMEOUT;
21 
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertFalse;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertNull;
26 import static org.junit.Assert.assertTrue;
27 import static org.mockito.Matchers.any;
28 import static org.mockito.Matchers.anyInt;
29 import static org.mockito.Mockito.doAnswer;
30 import static org.mockito.Mockito.mock;
31 import static org.mockito.Mockito.when;
32 
33 import android.content.ContentResolver;
34 import android.content.Context;
35 import android.os.Build;
36 import android.telecom.CallAudioState;
37 import android.telecom.Connection;
38 import android.telecom.DisconnectCause;
39 import android.telecom.InCallService;
40 import android.telecom.Log;
41 import android.telecom.Logging.EventManager;
42 import android.telecom.ParcelableCallAnalytics;
43 import android.telecom.TelecomAnalytics;
44 import android.telecom.TelecomManager;
45 import android.telecom.VideoCallImpl;
46 import android.telecom.VideoProfile;
47 import android.telephony.SubscriptionInfo;
48 import android.telephony.SubscriptionManager;
49 import android.test.suitebuilder.annotation.MediumTest;
50 import android.test.suitebuilder.annotation.SmallTest;
51 import android.util.Base64;
52 
53 import androidx.test.filters.FlakyTest;
54 
55 import com.android.internal.util.IndentingPrintWriter;
56 import com.android.server.telecom.Analytics;
57 import com.android.server.telecom.CallAudioRouteStateMachine;
58 import com.android.server.telecom.LogUtils;
59 import com.android.server.telecom.nano.TelecomLogClass;
60 
61 import org.junit.After;
62 import org.junit.Before;
63 import org.junit.Test;
64 import org.junit.runner.RunWith;
65 import org.junit.runners.JUnit4;
66 
67 import java.io.PrintWriter;
68 import java.io.StringWriter;
69 import java.util.Arrays;
70 import java.util.Collections;
71 import java.util.HashSet;
72 import java.util.LinkedList;
73 import java.util.List;
74 import java.util.Map;
75 import java.util.Set;
76 import java.util.concurrent.CountDownLatch;
77 import java.util.concurrent.TimeUnit;
78 
79 @RunWith(JUnit4.class)
80 public class AnalyticsTests extends TelecomSystemTest {
81     private SubscriptionManager mSubscriptionManager;
82 
83     @Override
84     @Before
setUp()85     public void setUp() throws Exception {
86         super.setUp();
87         // this is a mock
88         mSubscriptionManager = mContext.getSystemService(SubscriptionManager.class);
89         when(mSubscriptionManager.getActiveSubscriptionInfoList())
90                 .thenReturn(Collections.emptyList());
91     }
92 
93     @Override
94     @After
tearDown()95     public void tearDown() throws Exception {
96         super.tearDown();
97     }
98 
99     @MediumTest
100     @Test
testAnalyticsSingleCall()101     public void testAnalyticsSingleCall() throws Exception {
102         IdPair testCall = startAndMakeActiveIncomingCall(
103                 "650-555-1212",
104                 mPhoneAccountA0.getAccountHandle(),
105                 mConnectionServiceFixtureA);
106 
107         Map<String, Analytics.CallInfoImpl> analyticsMap = Analytics.cloneData();
108 
109         assertTrue(analyticsMap.containsKey(testCall.mCallId));
110 
111         Analytics.CallInfoImpl callAnalytics = analyticsMap.get(testCall.mCallId);
112         assertTrue(callAnalytics.startTime > 0);
113         assertEquals(0, callAnalytics.endTime);
114         assertEquals(Analytics.INCOMING_DIRECTION, callAnalytics.callDirection);
115         assertFalse(callAnalytics.isInterrupted);
116         assertNull(callAnalytics.callTerminationReason);
117         assertEquals(mConnectionServiceComponentNameA.flattenToShortString(),
118                 callAnalytics.connectionService);
119 
120         mConnectionServiceFixtureA.
121                 sendSetDisconnected(testCall.mConnectionId, DisconnectCause.ERROR);
122 
123         analyticsMap = Analytics.cloneData();
124         callAnalytics = analyticsMap.get(testCall.mCallId);
125         assertTrue(callAnalytics.endTime > 0);
126         assertNotNull(callAnalytics.callTerminationReason);
127         assertEquals(DisconnectCause.ERROR, callAnalytics.callTerminationReason.getCode());
128 
129         StringWriter sr = new StringWriter();
130         IndentingPrintWriter ip = new IndentingPrintWriter(sr, "    ");
131         Analytics.dump(ip);
132         String dumpResult = sr.toString();
133         String[] expectedFields = {"startTime", "endTime", "direction", "isAdditionalCall",
134                 "isInterrupted", "callTechnologies", "callTerminationReason", "connectionService",
135                 "missedReason"};
136         for (String field : expectedFields) {
137             assertTrue(dumpResult.contains(field));
138         }
139     }
140 
141     @FlakyTest
142     @MediumTest
143     @Test
testAnalyticsDumping()144     public void testAnalyticsDumping() throws Exception {
145         Analytics.reset();
146         IdPair testCall = startAndMakeActiveIncomingCall(
147                 "650-555-1212",
148                 mPhoneAccountA0.getAccountHandle(),
149                 mConnectionServiceFixtureA);
150 
151         mConnectionServiceFixtureA.
152                 sendSetDisconnected(testCall.mConnectionId, DisconnectCause.ERROR);
153         Analytics.CallInfoImpl expectedAnalytics = Analytics.cloneData().get(testCall.mCallId);
154 
155         TelecomManager tm = (TelecomManager) mSpyContext.getSystemService(Context.TELECOM_SERVICE);
156         List<ParcelableCallAnalytics> analyticsList = tm.dumpAnalytics().getCallAnalytics();
157 
158         assertEquals(1, analyticsList.size());
159         ParcelableCallAnalytics pCA = analyticsList.get(0);
160 
161         assertTrue(Math.abs(expectedAnalytics.startTime - pCA.getStartTimeMillis()) <
162                 ParcelableCallAnalytics.MILLIS_IN_5_MINUTES);
163         assertEquals(0, pCA.getStartTimeMillis() % ParcelableCallAnalytics.MILLIS_IN_5_MINUTES);
164         assertTrue(Math.abs((expectedAnalytics.endTime - expectedAnalytics.startTime) -
165                 pCA.getCallDurationMillis()) < ParcelableCallAnalytics.MILLIS_IN_1_SECOND);
166         assertEquals(0, pCA.getCallDurationMillis() % ParcelableCallAnalytics.MILLIS_IN_1_SECOND);
167 
168         assertEquals(expectedAnalytics.callDirection, pCA.getCallType());
169         assertEquals(expectedAnalytics.isAdditionalCall, pCA.isAdditionalCall());
170         assertEquals(expectedAnalytics.isInterrupted, pCA.isInterrupted());
171         assertEquals(expectedAnalytics.callTechnologies, pCA.getCallTechnologies());
172         assertEquals(expectedAnalytics.callTerminationReason.getCode(),
173                 pCA.getCallTerminationCode());
174         assertEquals(expectedAnalytics.connectionService, pCA.getConnectionService());
175         List<ParcelableCallAnalytics.AnalyticsEvent> analyticsEvents = pCA.analyticsEvents();
176         Set<Integer> capturedEvents = new HashSet<>();
177         for (ParcelableCallAnalytics.AnalyticsEvent e : analyticsEvents) {
178             capturedEvents.add(e.getEventName());
179             assertIsRoundedToOneSigFig(e.getTimeSinceLastEvent());
180         }
181         assertTrue(capturedEvents.contains(ParcelableCallAnalytics.AnalyticsEvent.SET_ACTIVE));
182         assertTrue(capturedEvents.contains(
183                 ParcelableCallAnalytics.AnalyticsEvent.FILTERING_INITIATED));
184     }
185 
186     @MediumTest
187     @Test
188     public void testAnalyticsTwoCalls() throws Exception {
189         when(mTimeoutsAdapter.getCallScreeningTimeoutMillis(any(ContentResolver.class)))
190                 .thenReturn((long) TEST_TIMEOUT);
191         IdPair testCall1 = startAndMakeActiveIncomingCall(
192                 "650-555-1212",
193                 mPhoneAccountA0.getAccountHandle(),
194                 mConnectionServiceFixtureA);
195         IdPair testCall2 = startAndMakeActiveOutgoingCall(
196                 "650-555-1213",
197                 mPhoneAccountA0.getAccountHandle(),
198                 mConnectionServiceFixtureA);
199 
200         Map<String, Analytics.CallInfoImpl> analyticsMap = Analytics.cloneData();
201         assertTrue(analyticsMap.containsKey(testCall1.mCallId));
202         assertTrue(analyticsMap.containsKey(testCall2.mCallId));
203 
204         Analytics.CallInfoImpl callAnalytics1 = analyticsMap.get(testCall1.mCallId);
205         Analytics.CallInfoImpl callAnalytics2 = analyticsMap.get(testCall2.mCallId);
206         assertTrue(callAnalytics1.startTime > 0);
207         assertTrue(callAnalytics2.startTime > 0);
208         assertEquals(0, callAnalytics1.endTime);
209         assertEquals(0, callAnalytics2.endTime);
210         long missedReason1 = callAnalytics1.missedReason;
211         assertTrue(missedReason1 == MISSED_REASON_NOT_MISSED
212                 || missedReason1 == USER_MISSED_CALL_FILTERS_TIMEOUT);
213         assertEquals(MISSED_REASON_NOT_MISSED, callAnalytics2.missedReason);
214 
215         assertEquals(Analytics.INCOMING_DIRECTION, callAnalytics1.callDirection);
216         assertEquals(Analytics.OUTGOING_DIRECTION, callAnalytics2.callDirection);
217 
218         assertTrue(callAnalytics1.isInterrupted);
219         assertTrue(callAnalytics2.isAdditionalCall);
220 
221         assertNull(callAnalytics1.callTerminationReason);
222         assertNull(callAnalytics2.callTerminationReason);
223 
224         assertEquals(mConnectionServiceComponentNameA.flattenToShortString(),
225                 callAnalytics1.connectionService);
226         assertEquals(mConnectionServiceComponentNameA.flattenToShortString(),
227                 callAnalytics1.connectionService);
228 
229         mConnectionServiceFixtureA.
230                 sendSetDisconnected(testCall2.mConnectionId, DisconnectCause.REMOTE);
231         mConnectionServiceFixtureA.
232                 sendSetDisconnected(testCall1.mConnectionId, DisconnectCause.ERROR);
233 
234         analyticsMap = Analytics.cloneData();
235         callAnalytics1 = analyticsMap.get(testCall1.mCallId);
236         callAnalytics2 = analyticsMap.get(testCall2.mCallId);
237         assertTrue(callAnalytics1.endTime > 0);
238         assertTrue(callAnalytics2.endTime > 0);
239         assertNotNull(callAnalytics1.callTerminationReason);
240         assertNotNull(callAnalytics2.callTerminationReason);
241         assertEquals(DisconnectCause.ERROR, callAnalytics1.callTerminationReason.getCode());
242         assertEquals(DisconnectCause.REMOTE, callAnalytics2.callTerminationReason.getCode());
243     }
244 
245     @MediumTest
246     @Test
testAnalyticsVideo()247     public void testAnalyticsVideo() throws Exception {
248         Analytics.reset();
249         IdPair callIds = startAndMakeActiveOutgoingCall(
250                 "650-555-1212",
251                 mPhoneAccountA0.getAccountHandle(),
252                 mConnectionServiceFixtureA);
253 
254         CountDownLatch counter = new CountDownLatch(1);
255         InCallService.VideoCall.Callback callback = mock(InCallService.VideoCall.Callback.class);
256 
257         doAnswer(invocation -> {
258             counter.countDown();
259             return null;
260         }).when(callback)
261                 .onSessionModifyResponseReceived(anyInt(), any(VideoProfile.class),
262                         any(VideoProfile.class));
263 
264         mConnectionServiceFixtureA.sendSetVideoProvider(
265                 mConnectionServiceFixtureA.mLatestConnectionId);
266         InCallService.VideoCall videoCall =
267                 mInCallServiceFixtureX.getCall(callIds.mCallId).getVideoCallImpl(
268                         mInCallServiceComponentNameX.getPackageName(), Build.VERSION.SDK_INT);
269         videoCall.registerCallback(callback);
270         ((VideoCallImpl) videoCall).setVideoState(VideoProfile.STATE_BIDIRECTIONAL);
271 
272         videoCall.sendSessionModifyRequest(new VideoProfile(VideoProfile.STATE_RX_ENABLED));
273         counter.await(10000, TimeUnit.MILLISECONDS);
274 
275         StringWriter sw = new StringWriter();
276         PrintWriter pw = new PrintWriter(sw);
277         Analytics.dumpToEncodedProto(mContext, pw, new String[]{});
278         TelecomLogClass.TelecomLog analyticsProto =
279                 TelecomLogClass.TelecomLog.parseFrom(Base64.decode(sw.toString(), Base64.DEFAULT));
280 
281         assertEquals(1, analyticsProto.callLogs.length);
282         TelecomLogClass.VideoEvent[] videoEvents = analyticsProto.callLogs[0].videoEvents;
283         assertEquals(2, videoEvents.length);
284 
285         assertEquals(Analytics.SEND_LOCAL_SESSION_MODIFY_REQUEST, videoEvents[0].getEventName());
286         assertEquals(VideoProfile.STATE_RX_ENABLED, videoEvents[0].getVideoState());
287         assertEquals(-1, videoEvents[0].getTimeSinceLastEventMillis());
288 
289         assertEquals(Analytics.RECEIVE_REMOTE_SESSION_MODIFY_RESPONSE,
290                 videoEvents[1].getEventName());
291         assertEquals(VideoProfile.STATE_RX_ENABLED, videoEvents[1].getVideoState());
292         assertIsRoundedToOneSigFig(videoEvents[1].getTimeSinceLastEventMillis());
293     }
294 
295     @SmallTest
296     @Test
testAnalyticsRounding()297     public void testAnalyticsRounding() {
298         long[] testVals = {0, -1, -10, -100, -57836, 1, 10, 100, 1000, 458457};
299         long[] expected = {0, -1, -10, -100, -60000, 1, 10, 100, 1000, 500000};
300         for (int i = 0; i < testVals.length; i++) {
301             assertEquals(expected[i], Analytics.roundToOneSigFig(testVals[i]));
302         }
303     }
304 
305     @SmallTest
306     @Test
testAnalyticsLogSessionTiming()307     public void testAnalyticsLogSessionTiming() throws Exception {
308         long minTime = 50;
309         Log.startSession(LogUtils.Sessions.CSW_ADD_CONFERENCE_CALL);
310         Thread.sleep(minTime);
311         Log.endSession();
312         TelecomManager tm = (TelecomManager) mSpyContext.getSystemService(Context.TELECOM_SERVICE);
313         List<TelecomAnalytics.SessionTiming> sessions = tm.dumpAnalytics().getSessionTimings();
314         sessions.stream()
315                 .filter(s -> LogUtils.Sessions.CSW_ADD_CONFERENCE_CALL.equals(
316                         Analytics.sSessionIdToLogSession.get(s.getKey())))
317                 .forEach(s -> assertTrue(s.getTime() >= minTime));
318     }
319 
320     @MediumTest
321     @Test
testAnalyticsDumpToProto()322     public void testAnalyticsDumpToProto() throws Exception {
323         Analytics.reset();
324         setupCarrierIds();
325         IdPair testCall = startAndMakeActiveIncomingCall(
326                 "650-555-1212",
327                 mPhoneAccountA0.getAccountHandle(),
328                 mConnectionServiceFixtureA);
329 
330         mConnectionServiceFixtureA.
331                 sendSetDisconnected(testCall.mConnectionId, DisconnectCause.ERROR);
332         Analytics.CallInfoImpl expectedAnalytics = Analytics.cloneData().get(testCall.mCallId);
333 
334         StringWriter sw = new StringWriter();
335         PrintWriter pw = new PrintWriter(sw);
336         Analytics.dumpToEncodedProto(mContext, pw, new String[]{});
337         TelecomLogClass.TelecomLog analyticsProto =
338                 TelecomLogClass.TelecomLog.parseFrom(Base64.decode(sw.toString(), Base64.DEFAULT));
339 
340         assertEquals(1, analyticsProto.getCarrierId());
341         assertEquals(1, analyticsProto.callLogs.length);
342         TelecomLogClass.CallLog callLog = analyticsProto.callLogs[0];
343 
344         assertTrue(Math.abs(expectedAnalytics.startTime - callLog.getStartTime5Min()) <
345                 ParcelableCallAnalytics.MILLIS_IN_5_MINUTES);
346         assertEquals(0, callLog.getStartTime5Min() % ParcelableCallAnalytics.MILLIS_IN_5_MINUTES);
347         assertTrue(Math.abs((expectedAnalytics.endTime - expectedAnalytics.startTime) -
348                 callLog.getCallDurationMillis()) < ParcelableCallAnalytics.MILLIS_IN_1_SECOND);
349         assertEquals(0,
350                 callLog.getCallDurationMillis() % ParcelableCallAnalytics.MILLIS_IN_1_SECOND);
351 
352         assertEquals(expectedAnalytics.callDirection, callLog.getType());
353         assertEquals(expectedAnalytics.isAdditionalCall, callLog.getIsAdditionalCall());
354         assertEquals(expectedAnalytics.isInterrupted, callLog.getIsInterrupted());
355         assertEquals(expectedAnalytics.callTechnologies, callLog.getCallTechnologies());
356         assertEquals(expectedAnalytics.callTerminationReason.getCode(),
357                 callLog.getCallTerminationCode());
358         assertEquals(expectedAnalytics.connectionService, callLog.connectionService[0]);
359         TelecomLogClass.Event[] analyticsEvents = callLog.callEvents;
360         Set<Integer> capturedEvents = new HashSet<>();
361         for (TelecomLogClass.Event e : analyticsEvents) {
362             capturedEvents.add(e.getEventName());
363             assertIsRoundedToOneSigFig(e.getTimeSinceLastEventMillis());
364         }
365         assertTrue(capturedEvents.contains(ParcelableCallAnalytics.AnalyticsEvent.SET_ACTIVE));
366         assertTrue(capturedEvents.contains(
367                 ParcelableCallAnalytics.AnalyticsEvent.FILTERING_INITIATED));
368     }
369 
370     @MediumTest
371     @Test
372     public void testAnalyticsAudioRoutes() throws Exception {
373         Analytics.reset();
374         IdPair testCall = startAndMakeActiveIncomingCall(
375                 "650-555-1212",
376                 mPhoneAccountA0.getAccountHandle(),
377                 mConnectionServiceFixtureA);
378         List<Integer> audioRoutes = new LinkedList<>();
379 
380         waitForHandlerAction(
381                 mTelecomSystem.getCallsManager().getCallAudioManager()
382                         .getCallAudioRouteStateMachine().getHandler(),
383                 TEST_TIMEOUT);
384         waitForHandlerAction(
385                 mTelecomSystem.getCallsManager().getCallAudioManager()
386                         .getCallAudioModeStateMachine().getHandler(),
387                 TEST_TIMEOUT);
388         audioRoutes.add(mInCallServiceFixtureX.mCallAudioState.getRoute());
389         mInCallServiceFixtureX.getInCallAdapter().setAudioRoute(CallAudioState.ROUTE_SPEAKER, null);
390         waitForHandlerAction(
391                 mTelecomSystem.getCallsManager().getCallAudioManager()
392                         .getCallAudioRouteStateMachine().getHandler(),
393                 TEST_TIMEOUT);
394         waitForHandlerAction(
395                 mTelecomSystem.getCallsManager().getCallAudioManager()
396                         .getCallAudioModeStateMachine().getHandler(),
397                 TEST_TIMEOUT);
398         audioRoutes.add(CallAudioState.ROUTE_SPEAKER);
399 
400         Map<String, Analytics.CallInfoImpl> analyticsMap = Analytics.cloneData();
401         assertTrue(analyticsMap.containsKey(testCall.mCallId));
402 
403         Analytics.CallInfoImpl callAnalytics = analyticsMap.get(testCall.mCallId);
404         List<EventManager.Event> events = callAnalytics.callEvents.getEvents();
405         for (int route : audioRoutes) {
406             String logEvent = CallAudioRouteStateMachine.AUDIO_ROUTE_TO_LOG_EVENT.get(route);
407             assertTrue(events.stream().anyMatch(event -> event.eventId.equals(logEvent)));
408         }
409     }
410 
411     @MediumTest
412     @Test
413     public void testAnalyticsConnectionProperties() throws Exception {
414         Analytics.reset();
415         IdPair testCall = startAndMakeActiveIncomingCall(
416                 "650-555-1212",
417                 mPhoneAccountA0.getAccountHandle(),
418                 mConnectionServiceFixtureA);
419 
420         int properties1 = Connection.PROPERTY_IS_DOWNGRADED_CONFERENCE
421                 | Connection.PROPERTY_WIFI
422                 | Connection.PROPERTY_EMERGENCY_CALLBACK_MODE;
423         int properties2 = Connection.PROPERTY_HIGH_DEF_AUDIO
424                 | Connection.PROPERTY_WIFI;
425         int expectedProperties = properties1 | properties2;
426 
427         mConnectionServiceFixtureA.mConnectionById.get(testCall.mConnectionId).properties =
428                 properties1;
429         mConnectionServiceFixtureA.sendSetConnectionProperties(testCall.mConnectionId);
430         mConnectionServiceFixtureA.mConnectionById.get(testCall.mConnectionId).properties =
431                 properties2;
432         mConnectionServiceFixtureA.sendSetConnectionProperties(testCall.mConnectionId);
433 
434         mConnectionServiceFixtureA.
435                 sendSetDisconnected(testCall.mConnectionId, DisconnectCause.ERROR);
436 
437         StringWriter sw = new StringWriter();
438         PrintWriter pw = new PrintWriter(sw);
439         Analytics.dumpToEncodedProto(mContext, pw, new String[]{});
440         TelecomLogClass.TelecomLog analyticsProto =
441                 TelecomLogClass.TelecomLog.parseFrom(Base64.decode(sw.toString(), Base64.DEFAULT));
442 
443         assertEquals(expectedProperties,
444                 analyticsProto.callLogs[0].getConnectionProperties() & expectedProperties);
445     }
446 
447     @SmallTest
448     @Test
449     public void testAnalyticsMaxSize() throws Exception {
450         Analytics.reset();
451         for (int i = 0; i < Analytics.MAX_NUM_CALLS_TO_STORE * 2; i++) {
452             Analytics.initiateCallAnalytics(String.valueOf(i), Analytics.INCOMING_DIRECTION)
453                     .addCallTechnology(i);
454         }
455 
456         StringWriter sw = new StringWriter();
457         PrintWriter pw = new PrintWriter(sw);
458         Analytics.dumpToEncodedProto(mContext, pw, new String[]{});
459         TelecomLogClass.TelecomLog analyticsProto =
460                 TelecomLogClass.TelecomLog.parseFrom(Base64.decode(sw.toString(), Base64.DEFAULT));
461 
462         assertEquals(Analytics.MAX_NUM_CALLS_TO_STORE, analyticsProto.callLogs.length);
463         assertEquals(Arrays.stream(analyticsProto.callLogs)
464                 .filter(x -> x.getCallTechnologies() < 100)
465                 .count(), 0);
466     }
467 
468     private void assertIsRoundedToOneSigFig(long x) {
469         assertEquals(x, Analytics.roundToOneSigFig(x));
470     }
471 
472     private void setupCarrierIds() {
473         SubscriptionInfo subInfo1 = mock(SubscriptionInfo.class);
474         SubscriptionInfo subInfo2 = mock(SubscriptionInfo.class);
475         when(subInfo1.getCarrierId()).thenReturn(1);
476         when(subInfo2.getCarrierId()).thenReturn(2);
477         when(subInfo1.isOpportunistic()).thenReturn(false);
478         when(subInfo2.isOpportunistic()).thenReturn(true);
479         when(subInfo1.getSimSlotIndex()).thenReturn(0);
480         when(subInfo2.getSimSlotIndex()).thenReturn(1);
481         when(mSubscriptionManager.getActiveSubscriptionInfoList())
482                 .thenReturn(Arrays.asList(subInfo2, subInfo1));
483     }
484 }
485