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; 18 19import android.hardware.radio.V1_0.RadioError; 20import android.hardware.radio.V1_0.RadioResponseInfo; 21import android.hardware.radio.config.V1_0.IRadioConfigResponse; 22import android.hardware.radio.config.V1_0.SimSlotStatus; 23import android.telephony.Rlog; 24 25import com.android.internal.telephony.uicc.IccSlotStatus; 26 27import java.util.ArrayList; 28 29/** 30 * This class is the implementation of IRadioConfigResponse interface. 31 */ 32public class RadioConfigResponse extends IRadioConfigResponse.Stub { 33 private final RadioConfig mRadioConfig; 34 private static final String TAG = "RadioConfigResponse"; 35 36 public RadioConfigResponse(RadioConfig radioConfig) { 37 mRadioConfig = radioConfig; 38 } 39 40 /** 41 * Response function for IRadioConfig.getSimSlotsStatus(). 42 */ 43 public void getSimSlotsStatusResponse(RadioResponseInfo responseInfo, 44 ArrayList<SimSlotStatus> slotStatus) { 45 RILRequest rr = mRadioConfig.processResponse(responseInfo); 46 47 if (rr != null) { 48 ArrayList<IccSlotStatus> ret = RadioConfig.convertHalSlotStatus(slotStatus); 49 if (responseInfo.error == RadioError.NONE) { 50 // send response 51 RadioResponse.sendMessageResponse(rr.mResult, ret); 52 Rlog.d(TAG, rr.serialString() + "< " 53 + mRadioConfig.requestToString(rr.mRequest) + " " + ret.toString()); 54 } else { 55 rr.onError(responseInfo.error, ret); 56 Rlog.e(TAG, rr.serialString() + "< " 57 + mRadioConfig.requestToString(rr.mRequest) + " error " 58 + responseInfo.error); 59 } 60 61 } else { 62 Rlog.e(TAG, "getSimSlotsStatusResponse: Error " + responseInfo.toString()); 63 } 64 } 65 66 /** 67 * Response function for IRadioConfig.setSimSlotsMapping(). 68 */ 69 public void setSimSlotsMappingResponse(RadioResponseInfo responseInfo) { 70 RILRequest rr = mRadioConfig.processResponse(responseInfo); 71 72 if (rr != null) { 73 if (responseInfo.error == RadioError.NONE) { 74 // send response 75 RadioResponse.sendMessageResponse(rr.mResult, null); 76 Rlog.d(TAG, rr.serialString() + "< " 77 + mRadioConfig.requestToString(rr.mRequest)); 78 } else { 79 rr.onError(responseInfo.error, null); 80 Rlog.e(TAG, rr.serialString() + "< " 81 + mRadioConfig.requestToString(rr.mRequest) + " error " 82 + responseInfo.error); 83 } 84 } else { 85 Rlog.e(TAG, "setSimSlotsMappingResponse: Error " + responseInfo.toString()); 86 } 87 } 88 89 90} 91