Home | History | Annotate | Download | only in telephony
      1 /*
      2  * Copyright (C) 2006 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;
     18 
     19 
     20 /**
     21  * See also RIL_AppStatus in include/telephony/ril.h
     22  *
     23  * {@hide}
     24  */
     25 public class IccCardApplication {
     26     public enum AppType{
     27         APPTYPE_UNKNOWN,
     28         APPTYPE_SIM,
     29         APPTYPE_USIM,
     30         APPTYPE_RUIM,
     31         APPTYPE_CSIM
     32     };
     33 
     34     public enum AppState{
     35         APPSTATE_UNKNOWN,
     36         APPSTATE_DETECTED,
     37         APPSTATE_PIN,
     38         APPSTATE_PUK,
     39         APPSTATE_SUBSCRIPTION_PERSO,
     40         APPSTATE_READY;
     41 
     42         boolean isPinRequired() {
     43             return this == APPSTATE_PIN;
     44         }
     45 
     46         boolean isPukRequired() {
     47             return this == APPSTATE_PUK;
     48         }
     49 
     50         boolean isSubscriptionPersoEnabled() {
     51             return this == APPSTATE_SUBSCRIPTION_PERSO;
     52         }
     53 
     54         boolean isAppReady() {
     55             return this == APPSTATE_READY;
     56         }
     57 
     58         boolean isAppNotReady() {
     59             return this == APPSTATE_UNKNOWN  ||
     60                    this == APPSTATE_DETECTED;
     61         }
     62     };
     63 
     64     public enum PersoSubState{
     65         PERSOSUBSTATE_UNKNOWN,
     66         PERSOSUBSTATE_IN_PROGRESS,
     67         PERSOSUBSTATE_READY,
     68         PERSOSUBSTATE_SIM_NETWORK,
     69         PERSOSUBSTATE_SIM_NETWORK_SUBSET,
     70         PERSOSUBSTATE_SIM_CORPORATE,
     71         PERSOSUBSTATE_SIM_SERVICE_PROVIDER,
     72         PERSOSUBSTATE_SIM_SIM,
     73         PERSOSUBSTATE_SIM_NETWORK_PUK,
     74         PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK,
     75         PERSOSUBSTATE_SIM_CORPORATE_PUK,
     76         PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK,
     77         PERSOSUBSTATE_SIM_SIM_PUK,
     78         PERSOSUBSTATE_RUIM_NETWORK1,
     79         PERSOSUBSTATE_RUIM_NETWORK2,
     80         PERSOSUBSTATE_RUIM_HRPD,
     81         PERSOSUBSTATE_RUIM_CORPORATE,
     82         PERSOSUBSTATE_RUIM_SERVICE_PROVIDER,
     83         PERSOSUBSTATE_RUIM_RUIM,
     84         PERSOSUBSTATE_RUIM_NETWORK1_PUK,
     85         PERSOSUBSTATE_RUIM_NETWORK2_PUK,
     86         PERSOSUBSTATE_RUIM_HRPD_PUK,
     87         PERSOSUBSTATE_RUIM_CORPORATE_PUK,
     88         PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK,
     89         PERSOSUBSTATE_RUIM_RUIM_PUK;
     90 
     91         boolean isPersoSubStateUnknown() {
     92             return this == PERSOSUBSTATE_UNKNOWN;
     93         }
     94     };
     95 
     96     public AppType        app_type;
     97     public AppState       app_state;
     98     // applicable only if app_state == RIL_APPSTATE_SUBSCRIPTION_PERSO
     99     public PersoSubState  perso_substate;
    100     // null terminated string, e.g., from 0xA0, 0x00 -> 0x41, 0x30, 0x30, 0x30 */
    101     public String         aid;
    102     // null terminated string
    103     public String         app_label;
    104     // applicable to USIM and CSIM
    105     public int            pin1_replaced;
    106     public int            pin1;
    107     public int            pin2;
    108 
    109     AppType AppTypeFromRILInt(int type) {
    110         AppType newType;
    111         /* RIL_AppType ril.h */
    112         switch(type) {
    113             case 0: newType = AppType.APPTYPE_UNKNOWN; break;
    114             case 1: newType = AppType.APPTYPE_SIM;     break;
    115             case 2: newType = AppType.APPTYPE_USIM;    break;
    116             case 3: newType = AppType.APPTYPE_RUIM;    break;
    117             case 4: newType = AppType.APPTYPE_CSIM;    break;
    118             default:
    119                 throw new RuntimeException(
    120                             "Unrecognized RIL_AppType: " +type);
    121         }
    122         return newType;
    123     }
    124 
    125     AppState AppStateFromRILInt(int state) {
    126         AppState newState;
    127         /* RIL_AppState ril.h */
    128         switch(state) {
    129             case 0: newState = AppState.APPSTATE_UNKNOWN;  break;
    130             case 1: newState = AppState.APPSTATE_DETECTED; break;
    131             case 2: newState = AppState.APPSTATE_PIN; break;
    132             case 3: newState = AppState.APPSTATE_PUK; break;
    133             case 4: newState = AppState.APPSTATE_SUBSCRIPTION_PERSO; break;
    134             case 5: newState = AppState.APPSTATE_READY; break;
    135             default:
    136                 throw new RuntimeException(
    137                             "Unrecognized RIL_AppState: " +state);
    138         }
    139         return newState;
    140     }
    141 
    142     PersoSubState PersoSubstateFromRILInt(int substate) {
    143         PersoSubState newSubState;
    144         /* RIL_PeroSubstate ril.h */
    145         switch(substate) {
    146             case 0:  newSubState = PersoSubState.PERSOSUBSTATE_UNKNOWN;  break;
    147             case 1:  newSubState = PersoSubState.PERSOSUBSTATE_IN_PROGRESS; break;
    148             case 2:  newSubState = PersoSubState.PERSOSUBSTATE_READY; break;
    149             case 3:  newSubState = PersoSubState.PERSOSUBSTATE_SIM_NETWORK; break;
    150             case 4:  newSubState = PersoSubState.PERSOSUBSTATE_SIM_NETWORK_SUBSET; break;
    151             case 5:  newSubState = PersoSubState.PERSOSUBSTATE_SIM_CORPORATE; break;
    152             case 6:  newSubState = PersoSubState.PERSOSUBSTATE_SIM_SERVICE_PROVIDER; break;
    153             case 7:  newSubState = PersoSubState.PERSOSUBSTATE_SIM_SIM;  break;
    154             case 8:  newSubState = PersoSubState.PERSOSUBSTATE_SIM_NETWORK_PUK; break;
    155             case 9:  newSubState = PersoSubState.PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK; break;
    156             case 10: newSubState = PersoSubState.PERSOSUBSTATE_SIM_CORPORATE_PUK; break;
    157             case 11: newSubState = PersoSubState.PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK; break;
    158             case 12: newSubState = PersoSubState.PERSOSUBSTATE_SIM_SIM_PUK; break;
    159             case 13: newSubState = PersoSubState.PERSOSUBSTATE_RUIM_NETWORK1; break;
    160             case 14: newSubState = PersoSubState.PERSOSUBSTATE_RUIM_NETWORK2; break;
    161             case 15: newSubState = PersoSubState.PERSOSUBSTATE_RUIM_HRPD; break;
    162             case 16: newSubState = PersoSubState.PERSOSUBSTATE_RUIM_CORPORATE; break;
    163             case 17: newSubState = PersoSubState.PERSOSUBSTATE_RUIM_SERVICE_PROVIDER; break;
    164             case 18: newSubState = PersoSubState.PERSOSUBSTATE_RUIM_RUIM; break;
    165             case 19: newSubState = PersoSubState.PERSOSUBSTATE_RUIM_NETWORK1_PUK; break;
    166             case 20: newSubState = PersoSubState.PERSOSUBSTATE_RUIM_NETWORK2_PUK; break;
    167             case 21: newSubState = PersoSubState.PERSOSUBSTATE_RUIM_HRPD_PUK ; break;
    168             case 22: newSubState = PersoSubState.PERSOSUBSTATE_RUIM_CORPORATE_PUK; break;
    169             case 23: newSubState = PersoSubState.PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK; break;
    170             case 24: newSubState = PersoSubState.PERSOSUBSTATE_RUIM_RUIM_PUK; break;
    171             default:
    172                 throw new RuntimeException(
    173                             "Unrecognized RIL_PersoSubstate: " +substate);
    174         }
    175         return newSubState;
    176     }
    177 
    178 }
    179