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.telephony.SubscriptionInfo; 20 import android.text.TextUtils; 21 22 /** 23 * This class represents the status of the physical UICC slots. 24 */ 25 public class IccSlotStatus { 26 27 public enum SlotState { 28 SLOTSTATE_INACTIVE, 29 SLOTSTATE_ACTIVE; 30 } 31 32 public IccCardStatus.CardState cardState; 33 public SlotState slotState; 34 public int logicalSlotIndex; 35 public String atr; 36 public String iccid; 37 38 /** 39 * Set the cardState according to the input state. 40 */ setCardState(int state)41 public void setCardState(int state) { 42 switch(state) { 43 case 0: 44 cardState = IccCardStatus.CardState.CARDSTATE_ABSENT; 45 break; 46 case 1: 47 cardState = IccCardStatus.CardState.CARDSTATE_PRESENT; 48 break; 49 case 2: 50 cardState = IccCardStatus.CardState.CARDSTATE_ERROR; 51 break; 52 case 3: 53 cardState = IccCardStatus.CardState.CARDSTATE_RESTRICTED; 54 break; 55 default: 56 throw new RuntimeException("Unrecognized RIL_CardState: " + state); 57 } 58 } 59 60 /** 61 * Set the slotState according to the input state. 62 */ setSlotState(int state)63 public void setSlotState(int state) { 64 switch(state) { 65 case 0: 66 slotState = SlotState.SLOTSTATE_INACTIVE; 67 break; 68 case 1: 69 slotState = SlotState.SLOTSTATE_ACTIVE; 70 break; 71 default: 72 throw new RuntimeException("Unrecognized RIL_SlotState: " + state); 73 } 74 } 75 76 @Override toString()77 public String toString() { 78 StringBuilder sb = new StringBuilder(); 79 sb.append("IccSlotStatus {").append(cardState).append(",") 80 .append(slotState).append(",") 81 .append("logicalSlotIndex=").append(logicalSlotIndex).append(",") 82 .append("atr=").append(atr).append(",iccid=") 83 .append(SubscriptionInfo.givePrintableIccid(iccid)); 84 85 sb.append("}"); 86 return sb.toString(); 87 } 88 89 @Override equals(Object obj)90 public boolean equals(Object obj) { 91 if (this == obj) { 92 return true; 93 } 94 if (obj == null || getClass() != obj.getClass()) { 95 return false; 96 } 97 98 IccSlotStatus that = (IccSlotStatus) obj; 99 return (cardState == that.cardState) 100 && (slotState == that.slotState) 101 && (logicalSlotIndex == that.logicalSlotIndex) 102 && (TextUtils.equals(atr, that.atr)) 103 && (TextUtils.equals(iccid, that.iccid)); 104 } 105 106 } 107