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 17 package android.telephony.cts.externalimsservice; 18 19 import android.content.Intent; 20 import android.os.IBinder; 21 import android.telephony.ims.ImsReasonInfo; 22 import android.telephony.ims.cts.ImsUtils; 23 import android.telephony.ims.cts.TestImsService; 24 import android.telephony.ims.stub.ImsFeatureConfiguration; 25 import android.util.Log; 26 27 /** 28 * A test ImsService that is used for GTS Testing. This package is separate from the main test 29 * package because we need to have two packages available. 30 */ 31 32 public class TestExternalImsService extends TestImsService { 33 private static final String TAG = "CtsImsTestDeviceImsService"; 34 // TODO: Use ImsService.SERVICE_INTERFACE definition when it becomes public. 35 private static final String ACTION_BIND_IMS_SERVICE = "android.telephony.ims.ImsService"; 36 37 private final TestFrameworkConnection mBinder = new TestFrameworkConnection(); 38 39 // For local access of this Service. 40 public class TestFrameworkConnection extends ITestExternalImsService.Stub { waitForLatchCountdown(int latchIndex)41 public boolean waitForLatchCountdown(int latchIndex) { 42 return TestExternalImsService.this.waitForLatchCountdown(latchIndex); 43 } 44 setFeatureConfig(ImsFeatureConfiguration f)45 public void setFeatureConfig(ImsFeatureConfiguration f) { 46 TestExternalImsService.this.setFeatureConfig(f); 47 } 48 isRcsFeatureCreated()49 public boolean isRcsFeatureCreated() { 50 return (getRcsFeature() != null); 51 } 52 isMmTelFeatureCreated()53 public boolean isMmTelFeatureCreated() { 54 return (getMmTelFeature() != null); 55 } 56 resetState()57 public void resetState() { 58 TestExternalImsService.this.resetState(); 59 } 60 isTelephonyBound()61 public boolean isTelephonyBound() { 62 return TestExternalImsService.this.isTelephonyBound(); 63 } 64 onDeregistered(ImsReasonInfo reason)65 public void onDeregistered(ImsReasonInfo reason) { 66 getImsRegistration().onDeregistered(reason); 67 } 68 onRegistering(int registrationTech)69 public void onRegistering(int registrationTech) { 70 getImsRegistration().onRegistering(registrationTech); 71 } 72 onRegistered(int registrationTech)73 public void onRegistered(int registrationTech) { 74 getImsRegistration().onRegistered(registrationTech); 75 } 76 addCapabilities(long capabilities)77 public void addCapabilities(long capabilities) { 78 TestExternalImsService.this.addCapabilities(capabilities); 79 } 80 } 81 82 @Override onBind(Intent intent)83 public IBinder onBind(Intent intent) { 84 synchronized (mLock) { 85 if (ACTION_BIND_IMS_SERVICE.equals(intent.getAction())) { 86 if (ImsUtils.VDBG) { 87 Log.i(TAG, "onBind-Remote"); 88 } 89 mIsTelephonyBound = true; 90 return super.onBind(intent); 91 } 92 if (ImsUtils.VDBG) { 93 Log.i(TAG, "onBind-Local"); 94 } 95 return mBinder; 96 } 97 } 98 } 99