1 /* 2 * Copyright 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.uicc; 18 19 import android.text.TextUtils; 20 21 import com.android.internal.telephony.util.TelephonyUtils; 22 import com.android.telephony.Rlog; 23 24 import java.util.Arrays; 25 26 /** 27 * This class represents the status of the physical UICC slots. 28 */ 29 public class IccSlotStatus { 30 /* Added state active to check slotState in old HAL case.*/ 31 public static final int STATE_ACTIVE = 1; 32 33 public IccCardStatus.CardState cardState; 34 public String atr; 35 public String eid; 36 37 public IccSimPortInfo[] mSimPortInfos; 38 39 /** 40 * Set the cardState according to the input state. 41 */ setCardState(int state)42 public void setCardState(int state) { 43 switch(state) { 44 case 0: 45 cardState = IccCardStatus.CardState.CARDSTATE_ABSENT; 46 break; 47 case 1: 48 cardState = IccCardStatus.CardState.CARDSTATE_PRESENT; 49 break; 50 case 2: 51 cardState = IccCardStatus.CardState.CARDSTATE_ERROR; 52 break; 53 case 3: 54 cardState = IccCardStatus.CardState.CARDSTATE_RESTRICTED; 55 break; 56 default: 57 throw new RuntimeException("Unrecognized RIL_CardState: " + state); 58 } 59 } 60 61 @Override toString()62 public String toString() { 63 StringBuilder sb = new StringBuilder(); 64 sb.append("IccSlotStatus {").append(cardState).append(",") 65 .append("atr=").append(atr).append(",") 66 .append("eid=").append(Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, eid)).append(","); 67 if (mSimPortInfos != null) { 68 sb.append("num_ports=").append(mSimPortInfos.length); 69 for (int i =0; i < mSimPortInfos.length; i++) { 70 sb.append(", IccSimPortInfo-" + i + mSimPortInfos[i]); 71 } 72 } else { 73 sb.append("num_ports=null"); 74 } 75 sb.append("}"); 76 return sb.toString(); 77 } 78 79 @Override equals(Object obj)80 public boolean equals(Object obj) { 81 if (this == obj) { 82 return true; 83 } 84 if (obj == null || getClass() != obj.getClass()) { 85 return false; 86 } 87 88 IccSlotStatus that = (IccSlotStatus) obj; 89 return (cardState == that.cardState) 90 && (TextUtils.equals(atr, that.atr)) 91 && (TextUtils.equals(eid, that.eid)) 92 && Arrays.equals(mSimPortInfos, that.mSimPortInfos); 93 } 94 95 } 96