Home | History | Annotate | Download | only in ims
      1 /*
      2  * Copyright (C) 2017 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.internal.telephony.ims;
     18 
     19 import android.os.RemoteException;
     20 import android.telephony.ims.aidl.IImsConfig;
     21 import android.telephony.ims.aidl.IImsMmTelFeature;
     22 import android.telephony.ims.aidl.IImsRcsFeature;
     23 import android.telephony.ims.aidl.IImsRegistration;
     24 import android.telephony.ims.aidl.IImsServiceController;
     25 import android.telephony.ims.aidl.IImsServiceControllerListener;
     26 import android.telephony.ims.stub.ImsConfigImplBase;
     27 import android.telephony.ims.stub.ImsFeatureConfiguration;
     28 import android.telephony.ims.stub.ImsRegistrationImplBase;
     29 
     30 import com.android.ims.internal.IImsFeatureStatusCallback;
     31 
     32 import static org.mockito.Mockito.spy;
     33 
     34 /**
     35  * Test base implementation of the ImsServiceController, which is used as a mockito spy.
     36  */
     37 
     38 public class TestImsServiceControllerAdapter {
     39 
     40     public IImsFeatureStatusCallback mStatusCallback;
     41 
     42     public class ImsServiceControllerBinder extends IImsServiceController.Stub {
     43 
     44         @Override
     45         public void setListener(IImsServiceControllerListener l) {
     46         }
     47 
     48         @Override
     49         public IImsMmTelFeature createMmTelFeature(int slotId, IImsFeatureStatusCallback c) {
     50             return TestImsServiceControllerAdapter.this.createMMTelFeature(slotId);
     51         }
     52 
     53         @Override
     54         public IImsRcsFeature createRcsFeature(int slotId, IImsFeatureStatusCallback c) {
     55             return TestImsServiceControllerAdapter.this.createRcsFeature(slotId);
     56         }
     57 
     58         @Override
     59         public void removeImsFeature(int slotId, int featureType, IImsFeatureStatusCallback c)
     60                 throws RemoteException {
     61             TestImsServiceControllerAdapter.this.removeImsFeature(slotId, featureType);
     62         }
     63 
     64         @Override
     65         public ImsFeatureConfiguration querySupportedImsFeatures() {
     66             return null;
     67         }
     68 
     69         @Override
     70         public void notifyImsServiceReadyForFeatureCreation() {
     71         }
     72 
     73         @Override
     74         public IImsConfig getConfig(int slotId) throws RemoteException {
     75             return new ImsConfigImplBase().getIImsConfig();
     76         }
     77 
     78         @Override
     79         public IImsRegistration getRegistration(int slotId) throws RemoteException {
     80             return new ImsRegistrationImplBase().getBinder();
     81         }
     82 
     83         @Override
     84         public void enableIms(int slotId) {
     85         }
     86 
     87         @Override
     88         public void disableIms(int slotId) {
     89 
     90         }
     91 
     92     }
     93 
     94     private ImsServiceControllerBinder mBinder;
     95 
     96     public IImsServiceController getBinder() {
     97         if (mBinder == null) {
     98             mBinder = spy(new ImsServiceControllerBinder());
     99         }
    100 
    101         return mBinder;
    102     }
    103 
    104     // Used by Mockito for verification that this method is being called in spy
    105     public IImsMmTelFeature createMMTelFeature(int slotId) {
    106         return null;
    107     }
    108 
    109     // Used by Mockito for verification that this method is being called in spy
    110     public IImsRcsFeature createRcsFeature(int slotId) {
    111         return null;
    112     }
    113 
    114     // Used by Mockito for verification that this method is being called in spy
    115     public void removeImsFeature(int subId, int feature) throws RemoteException {
    116     }
    117 }
    118