14e10a61602bd065cdf71d0335493ac3444d5055ayinxu/* 24e10a61602bd065cdf71d0335493ac3444d5055ayinxu * Copyright 2017 The Android Open Source Project 34e10a61602bd065cdf71d0335493ac3444d5055ayinxu * 44e10a61602bd065cdf71d0335493ac3444d5055ayinxu * Licensed under the Apache License, Version 2.0 (the "License"); 54e10a61602bd065cdf71d0335493ac3444d5055ayinxu * you may not use this file except in compliance with the License. 64e10a61602bd065cdf71d0335493ac3444d5055ayinxu * You may obtain a copy of the License at 74e10a61602bd065cdf71d0335493ac3444d5055ayinxu * 84e10a61602bd065cdf71d0335493ac3444d5055ayinxu * http://www.apache.org/licenses/LICENSE-2.0 94e10a61602bd065cdf71d0335493ac3444d5055ayinxu * 104e10a61602bd065cdf71d0335493ac3444d5055ayinxu * Unless required by applicable law or agreed to in writing, software 114e10a61602bd065cdf71d0335493ac3444d5055ayinxu * distributed under the License is distributed on an "AS IS" BASIS, 124e10a61602bd065cdf71d0335493ac3444d5055ayinxu * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134e10a61602bd065cdf71d0335493ac3444d5055ayinxu * See the License for the specific language governing permissions and 144e10a61602bd065cdf71d0335493ac3444d5055ayinxu * limitations under the License. 154e10a61602bd065cdf71d0335493ac3444d5055ayinxu */ 164e10a61602bd065cdf71d0335493ac3444d5055ayinxu 174e10a61602bd065cdf71d0335493ac3444d5055ayinxupackage com.android.internal.telephony.uicc; 184e10a61602bd065cdf71d0335493ac3444d5055ayinxu 194e10a61602bd065cdf71d0335493ac3444d5055ayinxuimport android.telephony.SubscriptionInfo; 200dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajanimport android.text.TextUtils; 214e10a61602bd065cdf71d0335493ac3444d5055ayinxu 224e10a61602bd065cdf71d0335493ac3444d5055ayinxu/** 234e10a61602bd065cdf71d0335493ac3444d5055ayinxu * This class represents the status of the physical UICC slots. 244e10a61602bd065cdf71d0335493ac3444d5055ayinxu */ 254e10a61602bd065cdf71d0335493ac3444d5055ayinxupublic class IccSlotStatus { 264e10a61602bd065cdf71d0335493ac3444d5055ayinxu 274e10a61602bd065cdf71d0335493ac3444d5055ayinxu public enum SlotState { 284e10a61602bd065cdf71d0335493ac3444d5055ayinxu SLOTSTATE_INACTIVE, 294e10a61602bd065cdf71d0335493ac3444d5055ayinxu SLOTSTATE_ACTIVE; 304e10a61602bd065cdf71d0335493ac3444d5055ayinxu } 314e10a61602bd065cdf71d0335493ac3444d5055ayinxu 324e10a61602bd065cdf71d0335493ac3444d5055ayinxu public IccCardStatus.CardState cardState; 334e10a61602bd065cdf71d0335493ac3444d5055ayinxu public SlotState slotState; 344e10a61602bd065cdf71d0335493ac3444d5055ayinxu public int logicalSlotIndex; 354e10a61602bd065cdf71d0335493ac3444d5055ayinxu public String atr; 364e10a61602bd065cdf71d0335493ac3444d5055ayinxu public String iccid; 374e10a61602bd065cdf71d0335493ac3444d5055ayinxu 384e10a61602bd065cdf71d0335493ac3444d5055ayinxu /** 394e10a61602bd065cdf71d0335493ac3444d5055ayinxu * Set the cardState according to the input state. 404e10a61602bd065cdf71d0335493ac3444d5055ayinxu */ 414e10a61602bd065cdf71d0335493ac3444d5055ayinxu public void setCardState(int state) { 424e10a61602bd065cdf71d0335493ac3444d5055ayinxu switch(state) { 434e10a61602bd065cdf71d0335493ac3444d5055ayinxu case 0: 444e10a61602bd065cdf71d0335493ac3444d5055ayinxu cardState = IccCardStatus.CardState.CARDSTATE_ABSENT; 454e10a61602bd065cdf71d0335493ac3444d5055ayinxu break; 464e10a61602bd065cdf71d0335493ac3444d5055ayinxu case 1: 474e10a61602bd065cdf71d0335493ac3444d5055ayinxu cardState = IccCardStatus.CardState.CARDSTATE_PRESENT; 484e10a61602bd065cdf71d0335493ac3444d5055ayinxu break; 494e10a61602bd065cdf71d0335493ac3444d5055ayinxu case 2: 504e10a61602bd065cdf71d0335493ac3444d5055ayinxu cardState = IccCardStatus.CardState.CARDSTATE_ERROR; 514e10a61602bd065cdf71d0335493ac3444d5055ayinxu break; 524e10a61602bd065cdf71d0335493ac3444d5055ayinxu case 3: 534e10a61602bd065cdf71d0335493ac3444d5055ayinxu cardState = IccCardStatus.CardState.CARDSTATE_RESTRICTED; 544e10a61602bd065cdf71d0335493ac3444d5055ayinxu break; 554e10a61602bd065cdf71d0335493ac3444d5055ayinxu default: 564e10a61602bd065cdf71d0335493ac3444d5055ayinxu throw new RuntimeException("Unrecognized RIL_CardState: " + state); 574e10a61602bd065cdf71d0335493ac3444d5055ayinxu } 584e10a61602bd065cdf71d0335493ac3444d5055ayinxu } 594e10a61602bd065cdf71d0335493ac3444d5055ayinxu 604e10a61602bd065cdf71d0335493ac3444d5055ayinxu /** 614e10a61602bd065cdf71d0335493ac3444d5055ayinxu * Set the slotState according to the input state. 624e10a61602bd065cdf71d0335493ac3444d5055ayinxu */ 634e10a61602bd065cdf71d0335493ac3444d5055ayinxu public void setSlotState(int state) { 644e10a61602bd065cdf71d0335493ac3444d5055ayinxu switch(state) { 654e10a61602bd065cdf71d0335493ac3444d5055ayinxu case 0: 664e10a61602bd065cdf71d0335493ac3444d5055ayinxu slotState = SlotState.SLOTSTATE_INACTIVE; 674e10a61602bd065cdf71d0335493ac3444d5055ayinxu break; 684e10a61602bd065cdf71d0335493ac3444d5055ayinxu case 1: 694e10a61602bd065cdf71d0335493ac3444d5055ayinxu slotState = SlotState.SLOTSTATE_ACTIVE; 704e10a61602bd065cdf71d0335493ac3444d5055ayinxu break; 714e10a61602bd065cdf71d0335493ac3444d5055ayinxu default: 724e10a61602bd065cdf71d0335493ac3444d5055ayinxu throw new RuntimeException("Unrecognized RIL_SlotState: " + state); 734e10a61602bd065cdf71d0335493ac3444d5055ayinxu } 744e10a61602bd065cdf71d0335493ac3444d5055ayinxu } 754e10a61602bd065cdf71d0335493ac3444d5055ayinxu 764e10a61602bd065cdf71d0335493ac3444d5055ayinxu @Override 774e10a61602bd065cdf71d0335493ac3444d5055ayinxu public String toString() { 784e10a61602bd065cdf71d0335493ac3444d5055ayinxu StringBuilder sb = new StringBuilder(); 794e10a61602bd065cdf71d0335493ac3444d5055ayinxu sb.append("IccSlotStatus {").append(cardState).append(",") 804e10a61602bd065cdf71d0335493ac3444d5055ayinxu .append(slotState).append(",") 814e10a61602bd065cdf71d0335493ac3444d5055ayinxu .append("logicalSlotIndex=").append(logicalSlotIndex).append(",") 824e10a61602bd065cdf71d0335493ac3444d5055ayinxu .append("atr=").append(atr).append(",iccid=") 834e10a61602bd065cdf71d0335493ac3444d5055ayinxu .append(SubscriptionInfo.givePrintableIccid(iccid)); 844e10a61602bd065cdf71d0335493ac3444d5055ayinxu 854e10a61602bd065cdf71d0335493ac3444d5055ayinxu sb.append("}"); 864e10a61602bd065cdf71d0335493ac3444d5055ayinxu return sb.toString(); 874e10a61602bd065cdf71d0335493ac3444d5055ayinxu } 884e10a61602bd065cdf71d0335493ac3444d5055ayinxu 890dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan @Override 900dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan public boolean equals(Object obj) { 910dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan if (this == obj) { 920dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan return true; 930dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan } 940dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan if (obj == null || getClass() != obj.getClass()) { 950dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan return false; 960dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan } 970dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan 980dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan IccSlotStatus that = (IccSlotStatus) obj; 990dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan return (cardState == that.cardState) 1000dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan && (slotState == that.slotState) 1010dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan && (logicalSlotIndex == that.logicalSlotIndex) 1020dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan && (TextUtils.equals(atr, that.atr)) 1030dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan && (TextUtils.equals(iccid, that.iccid)); 1040dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan } 1050dd01fcb63aaf7ecd0b6873dd2df15a38044cbb1Amit Mahajan 1064e10a61602bd065cdf71d0335493ac3444d5055ayinxu} 107