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 17package com.android.internal.telephony.ims; 18 19import android.os.RemoteException; 20import android.telephony.ims.stub.ImsConfigImplBase; 21import android.util.Log; 22 23import com.android.ims.internal.IImsConfig; 24 25public class ImsConfigCompatAdapter extends ImsConfigImplBase { 26 27 private static final String TAG = "ImsConfigCompatAdapter"; 28 29 private final IImsConfig mOldConfigInterface; 30 31 // Compat constants 32 public static final int UNKNOWN = -1; 33 public static final int SUCCESS = 0; 34 public static final int FAILED = 1; 35 36 public ImsConfigCompatAdapter(IImsConfig config) { 37 mOldConfigInterface = config; 38 } 39 40 @Override 41 public int setConfig(int item, int value) { 42 try { 43 if (mOldConfigInterface.setProvisionedValue(item, value) == SUCCESS) { 44 return CONFIG_RESULT_SUCCESS; 45 } 46 } catch (RemoteException e) { 47 Log.w(TAG, "setConfig: item=" + item + " value=" + value + "failed: " 48 + e.getMessage()); 49 } 50 return CONFIG_RESULT_FAILED; 51 } 52 53 @Override 54 public int setConfig(int item, String value) { 55 try { 56 if (mOldConfigInterface.setProvisionedStringValue(item, value) == SUCCESS) { 57 return CONFIG_RESULT_SUCCESS; 58 } 59 } catch (RemoteException e) { 60 Log.w(TAG, "setConfig: item=" + item + " value=" + value + "failed: " 61 + e.getMessage()); 62 } 63 return CONFIG_RESULT_FAILED; 64 } 65 66 @Override 67 public int getConfigInt(int item) { 68 try { 69 int value = mOldConfigInterface.getProvisionedValue(item); 70 if (value != UNKNOWN) { 71 return value; 72 } 73 } catch (RemoteException e) { 74 Log.w(TAG, "getConfigInt: item=" + item + "failed: " + e.getMessage()); 75 } 76 return CONFIG_RESULT_UNKNOWN; 77 } 78 79 @Override 80 public String getConfigString(int item) { 81 try { 82 return mOldConfigInterface.getProvisionedStringValue(item); 83 } catch (RemoteException e) { 84 Log.w(TAG, "getConfigInt: item=" + item + "failed: " + e.getMessage()); 85 } 86 return null; 87 } 88} 89