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