1 /* 2 * Copyright (C) 2018 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.ims; 18 19 import android.os.IInterface; 20 import android.telephony.ims.feature.CapabilityChangeRequest; 21 import android.telephony.ims.feature.ImsFeature; 22 23 public class TestImsFeature extends ImsFeature { 24 25 26 public static final int CAPABILITY_TEST_1 = 1 << 0; 27 public static final int CAPABILITY_TEST_2 = 1 << 1; 28 29 public int setCapabilitiesResult = ImsFeature.CAPABILITY_SUCCESS; 30 public CapabilityChangeRequest lastRequest; 31 public int onFeatureRemovedCount = 0; 32 public int onFeatureReadyCount = 0; 33 34 public void testSetFeatureState(int featureState) { 35 setFeatureState(featureState); 36 } 37 38 public void capabilitiesStatusChanged(Capabilities c) { 39 notifyCapabilitiesStatusChanged(c); 40 } 41 42 @Override 43 public void changeEnabledCapabilities(CapabilityChangeRequest request, 44 CapabilityCallbackProxy c) { 45 lastRequest = request; 46 if (setCapabilitiesResult != ImsFeature.CAPABILITY_SUCCESS) { 47 // Take the first value to enable and return it as an error. 48 CapabilityChangeRequest.CapabilityPair capPair = request.getCapabilitiesToEnable() 49 .get(0); 50 c.onChangeCapabilityConfigurationError(capPair.getCapability(), capPair.getRadioTech(), 51 ImsFeature.CAPABILITY_ERROR_GENERIC); 52 } 53 } 54 55 @Override 56 public void onFeatureRemoved() { 57 onFeatureRemovedCount++; 58 } 59 60 @Override 61 public void onFeatureReady() { 62 onFeatureReadyCount++; 63 } 64 65 @Override 66 public IInterface getBinder() { 67 return null; 68 } 69 } 70