1 /* 2 * Copyright (C) 2022 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.services.telephony; 18 19 import static org.mockito.Mockito.mock; 20 import static org.mockito.Mockito.when; 21 22 import android.content.AttributionSource; 23 import android.content.Context; 24 import android.os.Process; 25 import android.telephony.TelephonyManager; 26 27 import com.android.internal.telephony.Phone; 28 import com.android.internal.telephony.PhoneConstants; 29 import com.android.phone.PhoneGlobals; 30 31 import org.mockito.ArgumentMatchers; 32 import org.mockito.Mock; 33 import org.mockito.MockitoAnnotations; 34 35 public class TestTelephonyConnectionSimple extends TelephonyConnection{ 36 37 @Mock 38 Context mMockContext; 39 40 @Mock 41 PhoneGlobals mPhoneGlobals; 42 43 private Phone mMockPhone; 44 cloneConnection()45 public TelephonyConnection cloneConnection() { 46 return this; 47 } 48 TestTelephonyConnectionSimple()49 public TestTelephonyConnectionSimple(){ 50 super(null, null, android.telecom.Call.Details.DIRECTION_INCOMING); 51 MockitoAnnotations.initMocks(this); 52 53 AttributionSource attributionSource = new AttributionSource.Builder( 54 Process.myUid()).build(); 55 56 mMockPhone = mock(Phone.class); 57 mMockContext = mock(Context.class); 58 mPhoneGlobals = mock(PhoneGlobals.class); 59 60 when(mMockPhone.getSubId()).thenReturn(1); 61 } 62 setMockPhone(Phone newPhone)63 public void setMockPhone(Phone newPhone) { 64 mMockPhone = newPhone; 65 } 66 67 @Override getPhone()68 public Phone getPhone() { 69 return mMockPhone; 70 } 71 72 } 73