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 enum MultipleEnabledProfilesMode { 34 /** 35 * If there is no jointly supported MEP mode, set supported MEP mode to NONE. 36 */ 37 NONE, 38 /** 39 * In case of MEP-A1, the ISD-R is selected on eSIM port 0 only and profiles are selected 40 * on eSIM ports 1 and higher, with the eSIM port being assigned by the LPA or platform. 41 */ 42 MEP_A1, 43 /** 44 * In case of MEP-A2, the ISD-R is selected on eSIM port 0 only and profiles are selected 45 * on eSIM ports 1 and higher, with the eSIM port being assigned by the eUICC. 46 */ 47 MEP_A2, 48 /** 49 * In case of MEP-B, profiles are selected on eSIM ports 0 and higher, with the ISD-R being 50 * selectable on any of these eSIM ports. 51 */ 52 MEP_B; 53 isMepAMode()54 public boolean isMepAMode() { 55 return (this == MEP_A1 || this == MEP_A2); 56 } 57 isMepA1Mode()58 public boolean isMepA1Mode() { 59 return this == MEP_A1; 60 } 61 isMepMode()62 public boolean isMepMode() { 63 return this != NONE; 64 } 65 } 66 67 public IccCardStatus.CardState cardState; 68 public String atr; 69 public String eid; 70 71 public IccSimPortInfo[] mSimPortInfos; 72 public MultipleEnabledProfilesMode mSupportedMepMode = MultipleEnabledProfilesMode.NONE; 73 74 /** 75 * Set the cardState according to the input state. 76 */ setCardState(int state)77 public void setCardState(int state) { 78 switch(state) { 79 case 0: 80 cardState = IccCardStatus.CardState.CARDSTATE_ABSENT; 81 break; 82 case 1: 83 cardState = IccCardStatus.CardState.CARDSTATE_PRESENT; 84 break; 85 case 2: 86 cardState = IccCardStatus.CardState.CARDSTATE_ERROR; 87 break; 88 case 3: 89 cardState = IccCardStatus.CardState.CARDSTATE_RESTRICTED; 90 break; 91 default: 92 throw new RuntimeException("Unrecognized RIL_CardState: " + state); 93 } 94 } 95 96 /** 97 * Set the MultipleEnabledProfilesMode according to the input mode. 98 */ setMultipleEnabledProfilesMode(int mode)99 public void setMultipleEnabledProfilesMode(int mode) { 100 switch(mode) { 101 case 0: 102 mSupportedMepMode = MultipleEnabledProfilesMode.NONE; 103 break; 104 case 1: 105 mSupportedMepMode = MultipleEnabledProfilesMode.MEP_A1; 106 break; 107 case 2: 108 mSupportedMepMode = MultipleEnabledProfilesMode.MEP_A2; 109 break; 110 case 3: 111 mSupportedMepMode = MultipleEnabledProfilesMode.MEP_B; 112 break; 113 default: 114 throw new RuntimeException("Unrecognized RIL_MultipleEnabledProfilesMode: " + mode); 115 } 116 } 117 118 @Override toString()119 public String toString() { 120 StringBuilder sb = new StringBuilder(); 121 sb.append("IccSlotStatus {").append(cardState).append(",") 122 .append("atr=").append(atr).append(",") 123 .append("eid=").append(Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, eid)).append(","); 124 if (mSimPortInfos != null) { 125 sb.append("num_ports=").append(mSimPortInfos.length); 126 for (int i =0; i < mSimPortInfos.length; i++) { 127 sb.append(", IccSimPortInfo-" + i + mSimPortInfos[i]); 128 } 129 } else { 130 sb.append("num_ports=null"); 131 } 132 sb.append(", SupportedMepMode=" + mSupportedMepMode); 133 sb.append("}"); 134 return sb.toString(); 135 } 136 137 @Override equals(Object obj)138 public boolean equals(Object obj) { 139 if (this == obj) { 140 return true; 141 } 142 if (obj == null || getClass() != obj.getClass()) { 143 return false; 144 } 145 146 IccSlotStatus that = (IccSlotStatus) obj; 147 return (cardState == that.cardState) 148 && (TextUtils.equals(atr, that.atr)) 149 && (TextUtils.equals(eid, that.eid)) 150 && Arrays.equals(mSimPortInfos, that.mSimPortInfos); 151 } 152 153 } 154