Home | History | Annotate | Download | only in gsm
      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.gsm;
     18 
     19 import android.os.Message;
     20 import android.util.Log;
     21 
     22 import com.android.internal.telephony.IccCard;
     23 import com.android.internal.telephony.IccCardApplication;
     24 import com.android.internal.telephony.IccConstants;
     25 import com.android.internal.telephony.IccFileHandler;
     26 import com.android.internal.telephony.Phone;
     27 
     28 /**
     29  * {@hide}
     30  */
     31 public final class SIMFileHandler extends IccFileHandler implements IccConstants {
     32     static final String LOG_TAG = "GSM";
     33     private Phone mPhone;
     34 
     35     //***** Instance Variables
     36 
     37     //***** Constructor
     38 
     39     SIMFileHandler(GSMPhone phone) {
     40         super(phone);
     41         mPhone = phone;
     42     }
     43 
     44     public void dispose() {
     45         super.dispose();
     46     }
     47 
     48     protected void finalize() {
     49         Log.d(LOG_TAG, "SIMFileHandler finalized");
     50     }
     51 
     52     //***** Overridden from IccFileHandler
     53 
     54     @Override
     55     public void handleMessage(Message msg) {
     56         super.handleMessage(msg);
     57     }
     58 
     59     protected String getEFPath(int efid) {
     60         // TODO(): DF_GSM can be 7F20 or 7F21 to handle backward compatibility.
     61         // Implement this after discussion with OEMs.
     62         switch(efid) {
     63         case EF_SMS:
     64             return MF_SIM + DF_TELECOM;
     65 
     66         case EF_EXT6:
     67         case EF_MWIS:
     68         case EF_MBI:
     69         case EF_SPN:
     70         case EF_AD:
     71         case EF_MBDN:
     72         case EF_PNN:
     73         case EF_SPDI:
     74         case EF_SST:
     75         case EF_CFIS:
     76             return MF_SIM + DF_GSM;
     77 
     78         case EF_MAILBOX_CPHS:
     79         case EF_VOICE_MAIL_INDICATOR_CPHS:
     80         case EF_CFF_CPHS:
     81         case EF_SPN_CPHS:
     82         case EF_SPN_SHORT_CPHS:
     83         case EF_INFO_CPHS:
     84             return MF_SIM + DF_GSM;
     85 
     86         case EF_PBR:
     87             // we only support global phonebook.
     88             return MF_SIM + DF_TELECOM + DF_PHONEBOOK;
     89         }
     90         String path = getCommonIccEFPath(efid);
     91         if (path == null) {
     92             // The EFids in USIM phone book entries are decided by the card manufacturer.
     93             // So if we don't match any of the cases above and if its a USIM return
     94             // the phone book path.
     95             IccCard card = phone.getIccCard();
     96             if (card != null && card.isApplicationOnIcc(IccCardApplication.AppType.APPTYPE_USIM)) {
     97                 return MF_SIM + DF_TELECOM + DF_PHONEBOOK;
     98             }
     99             Log.e(LOG_TAG, "Error: EF Path being returned in null");
    100         }
    101         return path;
    102     }
    103 
    104     protected void logd(String msg) {
    105         Log.d(LOG_TAG, "[SIMFileHandler] " + msg);
    106     }
    107 
    108     protected void loge(String msg) {
    109         Log.e(LOG_TAG, "[SIMFileHandler] " + msg);
    110     }
    111 }
    112