• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     public String     eid;
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     /**
62      * Set the slotState according to the input state.
63      */
setSlotState(int state)64     public void setSlotState(int state) {
65         switch(state) {
66             case 0:
67                 slotState = SlotState.SLOTSTATE_INACTIVE;
68                 break;
69             case 1:
70                 slotState = SlotState.SLOTSTATE_ACTIVE;
71                 break;
72             default:
73                 throw new RuntimeException("Unrecognized RIL_SlotState: " + state);
74         }
75     }
76 
77     @Override
toString()78     public String toString() {
79         StringBuilder sb = new StringBuilder();
80         sb.append("IccSlotStatus {").append(cardState).append(",")
81                 .append(slotState).append(",")
82                 .append("logicalSlotIndex=").append(logicalSlotIndex).append(",")
83                 .append("atr=").append(atr).append(",iccid=")
84                 .append(SubscriptionInfo.givePrintableIccid(iccid)).append(",")
85                 .append("eid=").append(eid);
86 
87         sb.append("}");
88         return sb.toString();
89     }
90 
91     @Override
equals(Object obj)92     public boolean equals(Object obj) {
93         if (this == obj) {
94             return true;
95         }
96         if (obj == null || getClass() != obj.getClass()) {
97             return false;
98         }
99 
100         IccSlotStatus that = (IccSlotStatus) obj;
101         return (cardState == that.cardState)
102                 && (slotState == that.slotState)
103                 && (logicalSlotIndex == that.logicalSlotIndex)
104                 && (TextUtils.equals(atr, that.atr))
105                 && (TextUtils.equals(iccid, that.iccid))
106                 && (TextUtils.equals(eid, that.eid));
107     }
108 
109 }
110