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
17package com.android.internal.telephony.gsm;
18
19import android.os.Message;
20import android.util.Log;
21
22import com.android.internal.telephony.IccCard;
23import com.android.internal.telephony.IccCardApplication;
24import com.android.internal.telephony.IccConstants;
25import com.android.internal.telephony.IccFileHandler;
26import com.android.internal.telephony.Phone;
27
28/**
29 * {@hide}
30 */
31public 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        case EF_CSP_CPHS:
85            return MF_SIM + DF_GSM;
86
87        case EF_PBR:
88            // we only support global phonebook.
89            return MF_SIM + DF_TELECOM + DF_PHONEBOOK;
90        }
91        String path = getCommonIccEFPath(efid);
92        if (path == null) {
93            // The EFids in USIM phone book entries are decided by the card manufacturer.
94            // So if we don't match any of the cases above and if its a USIM return
95            // the phone book path.
96            IccCard card = phone.getIccCard();
97            if (card != null && card.isApplicationOnIcc(IccCardApplication.AppType.APPTYPE_USIM)) {
98                return MF_SIM + DF_TELECOM + DF_PHONEBOOK;
99            }
100            Log.e(LOG_TAG, "Error: EF Path being returned in null");
101        }
102        return path;
103    }
104
105    protected void logd(String msg) {
106        Log.d(LOG_TAG, "[SIMFileHandler] " + msg);
107    }
108
109    protected void loge(String msg) {
110        Log.e(LOG_TAG, "[SIMFileHandler] " + msg);
111    }
112}
113