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 22 import java.util.concurrent.LinkedBlockingQueue; 23 24 public class TestAcsClient { 25 public static int ACTION_SET_RCS_CLIENT_CONFIG = 1; 26 public static int ACTION_TRIGGER_AUTO_CONFIG = 2; 27 public static int ACTION_CONFIG_CHANGED = 3; 28 public static int ACTION_CONFIG_REMOVED = 4; 29 30 private LinkedBlockingQueue<Integer> mActionQueue = new LinkedBlockingQueue<>(); 31 private RcsClientConfiguration mRcc; 32 private byte[] mConfig; 33 private ImsConfigImplBase mImsConfigImpl; 34 35 private static TestAcsClient sInstance; 36 TestAcsClient()37 private TestAcsClient() {} 38 getInstance()39 public static TestAcsClient getInstance() { 40 if (sInstance == null) { 41 sInstance = new TestAcsClient(); 42 } 43 return sInstance; 44 } 45 onSetRcsClientConfiguration(RcsClientConfiguration rcc)46 public void onSetRcsClientConfiguration(RcsClientConfiguration rcc) { 47 mActionQueue.offer(ACTION_SET_RCS_CLIENT_CONFIG); 48 mRcc = rcc; 49 } 50 onTriggerAutoConfiguration()51 public void onTriggerAutoConfiguration() { 52 mActionQueue.offer(ACTION_TRIGGER_AUTO_CONFIG); 53 } 54 onConfigChanged(byte[] config, boolean isCompressed)55 public void onConfigChanged(byte[] config, boolean isCompressed) { 56 mActionQueue.offer(ACTION_CONFIG_CHANGED); 57 mConfig = isCompressed ? ImsUtils.decompressGzip(config) : config; 58 } 59 onConfigRemoved()60 public void onConfigRemoved() { 61 mActionQueue.offer(ACTION_CONFIG_REMOVED); 62 mConfig = null; 63 } 64 getActionQueue()65 public LinkedBlockingQueue<Integer> getActionQueue() { 66 return mActionQueue; 67 } 68 getRcc()69 public RcsClientConfiguration getRcc() { 70 return mRcc; 71 } 72 getConfig()73 public byte[] getConfig() { 74 return mConfig; 75 } 76 reset()77 public void reset() { 78 mActionQueue.clear(); 79 mRcc = null; 80 mConfig = null; 81 } 82 setImsConfigImpl(ImsConfigImplBase impl)83 public void setImsConfigImpl(ImsConfigImplBase impl) { 84 mImsConfigImpl = impl; 85 } 86 notifyPreProvisioning(byte[] conf)87 public void notifyPreProvisioning(byte[] conf) { 88 mImsConfigImpl.notifyPreProvisioningReceived(conf); 89 } 90 } 91