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.ims.cts;
18 
19 import android.telephony.ims.RcsClientConfiguration;
20 import android.telephony.ims.stub.ImsConfigImplBase;
21 import android.util.Log;
22 
23 import java.util.HashMap;
24 import java.util.concurrent.Executor;
25 
26 public class TestImsConfig extends ImsConfigImplBase {
27 
28     private static final String TAG = "TestImsConfig";
29     private HashMap<Integer, Integer> mIntHashMap = new HashMap<>();
30     private HashMap<Integer, String> mStringHashMap = new HashMap<>();
31 
TestImsConfig()32     TestImsConfig() {
33         Log.d(TAG, "TestImsConfig with default constructor");
34         TestAcsClient.getInstance().setImsConfigImpl(this);
35     }
36 
TestImsConfig(Executor executor)37     TestImsConfig(Executor executor) {
38         super(executor);
39         Log.d(TAG, "TestImsConfig with Executor constructor");
40         TestAcsClient.getInstance().setImsConfigImpl(this);
41     }
42 
43     @Override
setConfig(int item, int value)44     public int setConfig(int item, int value) {
45         mIntHashMap.put(item, value);
46         return ImsConfigImplBase.CONFIG_RESULT_SUCCESS;
47     }
48 
49     @Override
setConfig(int item, String value)50     public int setConfig(int item, String value) {
51         mStringHashMap.put(item, value);
52         return ImsConfigImplBase.CONFIG_RESULT_SUCCESS;
53     }
54 
55     @Override
getConfigInt(int item)56     public int getConfigInt(int item) {
57         Integer result = mIntHashMap.get(item);
58         return result != null ? result : ImsConfigImplBase.CONFIG_RESULT_UNKNOWN;
59     }
60 
61     @Override
getConfigString(int item)62     public String getConfigString(int item) {
63         return mStringHashMap.get(item);
64     }
65 
66     @Override
notifyRcsAutoConfigurationReceived(byte[] content, boolean isCompressed)67     public void notifyRcsAutoConfigurationReceived(byte[] content, boolean isCompressed) {
68         TestAcsClient.getInstance().onConfigChanged(content, isCompressed);
69     }
70 
71     @Override
notifyRcsAutoConfigurationRemoved()72     public void notifyRcsAutoConfigurationRemoved() {
73         super.notifyRcsAutoConfigurationRemoved();
74         TestAcsClient.getInstance().onConfigRemoved();
75     }
76 
77     @Override
setRcsClientConfiguration(RcsClientConfiguration rcc)78     public void setRcsClientConfiguration(RcsClientConfiguration rcc) {
79         super.setRcsClientConfiguration(rcc);
80         TestAcsClient.getInstance().onSetRcsClientConfiguration(rcc);
81     }
82 
83     @Override
triggerAutoConfiguration()84     public void triggerAutoConfiguration() {
85         super.triggerAutoConfiguration();
86         TestAcsClient.getInstance().onTriggerAutoConfiguration();
87     }
88 }
89