EriManager.java revision f315238a2b07c7e84f6ade800e504f520d262e66
1e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville/*
2e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville * Licensed under the Apache License, Version 2.0 (the "License");
3e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville * you may not use this file except in compliance with the License.
4e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville * You may obtain a copy of the License at
5e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville *
6e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville *      http://www.apache.org/licenses/LICENSE-2.0
7e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville *
8e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville * Unless required by applicable law or agreed to in writing, software
9e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville * distributed under the License is distributed on an "AS IS" BASIS,
10e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville * See the License for the specific language governing permissions and
12e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville * limitations under the License.
13e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville */
14e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
15e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Savillepackage com.android.internal.telephony.cdma;
16e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
17e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Savilleimport android.content.Context;
18e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Savilleimport android.content.res.Resources;
19e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Savilleimport android.content.res.XmlResourceParser;
20e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Savilleimport android.os.Message;
21e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Savilleimport android.util.Log;
22e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
23e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Savilleimport com.android.internal.telephony.Phone;
24e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Savilleimport com.android.internal.telephony.PhoneBase;
25e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
26e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Savilleimport com.android.internal.util.XmlUtils;
27e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
28e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Savilleimport java.util.HashMap;
29e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
30e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville/**
31f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville * EriManager loads the ERI file definitions and manages the CDMA roaming information.
32f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville *
33e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville */
34e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Savillepublic final class EriManager {
35e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
36e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    class EriFile {
37e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
38e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        public int mVersionNumber;                      // File version number
39e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        public int mNumberOfEriEntries;                 // Number of entries
40e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        public int mEriFileType;                        // Eri Phase 0/1
41e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        //public int mNumberOfIconImages;               // reserved for future use
42e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        //public int mIconImageType;                    // reserved for future use
43e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        public String[] mCallPromptId;                  // reserved for future use
44e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        public HashMap<Integer, EriInfo> mRoamIndTable; // Roaming Indicator Table
45e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
46e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        public EriFile() {
47e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            this.mVersionNumber = -1;
48e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            this.mNumberOfEriEntries = 0;
49e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            this.mEriFileType = -1;
50e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            this.mCallPromptId = new String[] { "", "", "" };
51e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            this.mRoamIndTable = new HashMap<Integer, EriInfo>();
52e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        }
53f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville    }
54f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
55f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville    class EriDisplayInformation {
56f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        public int mEriIconIndex;
57f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        public int mEriIconMode;
58f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        public String mEriIconText;
59f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
60f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        public EriDisplayInformation(int eriIconIndex, int eriIconMode, String eriIconText) {
61f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            mEriIconIndex = eriIconIndex;
62f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            mEriIconMode = eriIconMode;
63f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            mEriIconText = eriIconText;
64f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        }
65f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
66f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville//        public void setParameters(int eriIconIndex, int eriIconMode, String eriIconText){
67f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville//            this.mEriIconIndex = eriIconIndex;
68f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville//            this.mEriIconMode = eriIconMode;
69f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville//            this.mEriIconText = eriIconText;
70f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville//        }
71e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
72f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        @Override
73f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        public String toString() {
74f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            return "EriDisplayInformation: {" + " IconIndex: " + mEriIconIndex + " EriIconMode: "
75f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    + mEriIconMode + " EriIconText: " + mEriIconText + " }";
76f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        }
77e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    }
78e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
79e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    static final String LOG_TAG = "CDMA";
80e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
81e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    public static final int ERI_FROM_XML          = 0;
82e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    public static final int ERI_FROM_FILE_SYSTEM  = 1;
83e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    public static final int ERI_FROM_MODEM        = 2;
84e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
85e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    private PhoneBase mPhone;
86e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    private Context mContext;
87e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    private int mEriFileSource = ERI_FROM_XML;
88f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville    private boolean isEriFileLoaded;
89e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    private EriFile mEriFile;
90e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
91e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    public EriManager(PhoneBase phone, Context context, int eriFileSource) {
92e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        this.mPhone = phone;
93e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        this.mContext = context;
94e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        this.mEriFileSource = eriFileSource;
95e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        this.mEriFile = new EriFile();
96e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    }
97e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
98e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    public void dispose() {
99e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        mEriFile = new EriFile();
100e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        isEriFileLoaded = false;
101e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    }
102e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
103e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
104e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    public void loadEriFile() {
105e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        switch (mEriFileSource) {
106e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        case ERI_FROM_MODEM:
107e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            loadEriFileFromModem();
108e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            break;
109e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
110e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        case ERI_FROM_FILE_SYSTEM:
111e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            loadEriFileFromFileSystem();
112e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            break;
113e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
114e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        case ERI_FROM_XML:
115e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        default:
116e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            loadEriFileFromXml();
117e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            break;
118e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        }
119e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    }
120e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
121e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    /**
122e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     * Load the ERI file from the MODEM through chipset specific RIL_REQUEST_OEM_HOOK
123e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     *
124e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     * In this case the ERI file can be updated from the Phone Support Tool available
125e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     * from the Chipset vendor
126e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     */
127e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    private void loadEriFileFromModem() {
128e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        // NOT IMPLEMENTED, Chipset vendor/Operator specific
129e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    }
130e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
131e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    /**
132e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     * Load the ERI file from a File System file
133e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     *
134e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     * In this case the a Phone Support Tool to update the ERI file must be provided
135e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     * to the Operator
136e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     */
137e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    private void loadEriFileFromFileSystem() {
138e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        // NOT IMPLEMENTED, Chipset vendor/Operator specific
139e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    }
140e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
141e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    /**
142e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     * Load the ERI file from the application framework resources encoded in XML
143e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     *
144e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     */
145e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    private void loadEriFileFromXml() {
146e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        Resources r = mContext.getResources();
147e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        XmlResourceParser parser = r.getXml(com.android.internal.R.xml.eri);
148e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        try {
149e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            XmlUtils.beginDocument(parser, "EriFile");
150e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            mEriFile.mVersionNumber = Integer.parseInt(
151e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    parser.getAttributeValue(null, "VersionNumber"));
152e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            mEriFile.mNumberOfEriEntries = Integer.parseInt(
153e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    parser.getAttributeValue(null, "NumberOfEriEntries"));
154e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            mEriFile.mEriFileType = Integer.parseInt(
155e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    parser.getAttributeValue(null, "EriFileType"));
156e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
157e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            int parsedEriEntries = 0;
158e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            while(true) {
159e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                XmlUtils.nextElement(parser);
160e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                String name = parser.getName();
161e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                if (name == null) {
162e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    if (parsedEriEntries != mEriFile.mNumberOfEriEntries)
163e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                        Log.e(LOG_TAG, "Error Parsing ERI file: " +  mEriFile.mNumberOfEriEntries
164e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                                + " defined, " + parsedEriEntries + " parsed!");
165e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    break;
166e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                } else if (name.equals("CallPromptId")) {
167e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    int id = Integer.parseInt(parser.getAttributeValue(null, "Id"));
168e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    String text = parser.getAttributeValue(null, "CallPromptText");
169e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    if (id >= 0 && id <= 2) {
170e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                        mEriFile.mCallPromptId[id] = text;
171e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    } else {
172e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                        Log.e(LOG_TAG, "Error Parsing ERI file: found" + id + " CallPromptId");
173e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    }
174e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
175e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                } else if (name.equals("EriInfo")) {
176e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    int roamingIndicator = Integer.parseInt(
177e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                            parser.getAttributeValue(null, "RoamingIndicator"));
178e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    int iconIndex = Integer.parseInt(parser.getAttributeValue(null, "IconIndex"));
179e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    int iconMode = Integer.parseInt(parser.getAttributeValue(null, "IconMode"));
180e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    String eriText = parser.getAttributeValue(null, "EriText");
181e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    int callPromptId = Integer.parseInt(
182e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                            parser.getAttributeValue(null, "CallPromptId"));
183e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    int alertId = Integer.parseInt(parser.getAttributeValue(null, "AlertId"));
184e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    parsedEriEntries++;
185e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                    mEriFile.mRoamIndTable.put(roamingIndicator, new EriInfo (roamingIndicator,
186e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                            iconIndex, iconMode, eriText, callPromptId, alertId));
187e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville                }
188e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            }
189e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
190e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            isEriFileLoaded = true;
191e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
192e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        } catch (Exception e) {
193e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            Log.e(LOG_TAG, "Got exception while loading ERI file.", e);
194e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        } finally {
195e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            parser.close();
196e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        }
197e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    }
198e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
199e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    /**
200e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     * Returns the version of the ERI file
201e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     *
202e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     */
203e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    public int getEriFileVersion() {
204e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        return mEriFile.mVersionNumber;
205e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    }
206e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
207e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    /**
208e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     * Returns the number of ERI entries parsed
209e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     *
210e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     */
211e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    public int getEriNumberOfEntries() {
212e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        return mEriFile.mNumberOfEriEntries;
213e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    }
214e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
215e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    /**
216e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     * Returns the ERI file type value ( 0 for Phase 0, 1 for Phase 1)
217e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     *
218e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     */
219e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    public int getEriFileType() {
220e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        return mEriFile.mEriFileType;
221e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    }
222e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
223e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    /**
224e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     * Returns if the ERI file has been loaded
225e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     *
226e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     */
227e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    public boolean isEriFileLoaded() {
228e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        return isEriFileLoaded;
229e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    }
230e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville
231e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    /**
232e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     * Returns the EriInfo record associated with roamingIndicator
233e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     * or null if the entry is not found
234e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville     */
235f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville    private EriInfo getEriInfo(int roamingIndicator) {
236e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        if (mEriFile.mRoamIndTable.containsKey(roamingIndicator)) {
237e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            return mEriFile.mRoamIndTable.get(roamingIndicator);
238e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        } else {
239e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville            return null;
240e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville        }
241e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville    }
242f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
243f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville    private EriDisplayInformation getEriDisplayInformation(int roamInd, int defRoamInd){
244f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        //int iconIndex = -1;
245f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        //int iconMode = -1;
246f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        //String iconText = "ERI text";
247f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        EriDisplayInformation ret;
248f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
249f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        switch (roamInd) {
250f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        // Handling the standard roaming indicator (non-ERI)
251f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        case EriInfo.ROAMING_INDICATOR_ON:
252f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            ret = new EriDisplayInformation(
253f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_INDICATOR_ON,
254f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_ICON_MODE_NORMAL,
255f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    mContext.getText(com.android.internal.R.string.roamingText0).toString());
256f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
257f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
258f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        case EriInfo.ROAMING_INDICATOR_OFF:
259f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            ret = new EriDisplayInformation(
260f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_INDICATOR_OFF,
261f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_ICON_MODE_NORMAL,
262f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    mContext.getText(com.android.internal.R.string.roamingText1).toString());
263f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
264f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
265f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        case EriInfo.ROAMING_INDICATOR_FLASH:
266f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            ret = new EriDisplayInformation(
267f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_INDICATOR_FLASH,
268f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_ICON_MODE_FLASH,
269f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    mContext.getText(com.android.internal.R.string.roamingText2).toString());
270f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
271f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
272f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
273f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        // Handling the standard ERI
274f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        case 3:
275f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            ret = new EriDisplayInformation(
276f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    roamInd,
277f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_ICON_MODE_NORMAL,
278f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    mContext.getText(com.android.internal.R.string.roamingText3).toString());
279f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
280f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
281f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        case 4:
282f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            ret = new EriDisplayInformation(
283f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    roamInd,
284f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_ICON_MODE_NORMAL,
285f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    mContext.getText(com.android.internal.R.string.roamingText4).toString());
286f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
287f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
288f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        case 5:
289f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            ret = new EriDisplayInformation(
290f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    roamInd,
291f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_ICON_MODE_NORMAL,
292f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    mContext.getText(com.android.internal.R.string.roamingText5).toString());
293f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
294f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
295f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        case 6:
296f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            ret = new EriDisplayInformation(
297f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    roamInd,
298f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_ICON_MODE_NORMAL,
299f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    mContext.getText(com.android.internal.R.string.roamingText6).toString());
300f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
301f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
302f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        case 7:
303f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            ret = new EriDisplayInformation(
304f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    roamInd,
305f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_ICON_MODE_NORMAL,
306f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    mContext.getText(com.android.internal.R.string.roamingText7).toString());
307f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
308f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
309f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        case 8:
310f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            ret = new EriDisplayInformation(
311f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    roamInd,
312f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_ICON_MODE_NORMAL,
313f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    mContext.getText(com.android.internal.R.string.roamingText8).toString());
314f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
315f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
316f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        case 9:
317f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            ret = new EriDisplayInformation(
318f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    roamInd,
319f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_ICON_MODE_NORMAL,
320f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    mContext.getText(com.android.internal.R.string.roamingText9).toString());
321f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
322f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
323f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        case 10:
324f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            ret = new EriDisplayInformation(
325f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    roamInd,
326f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_ICON_MODE_NORMAL,
327f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    mContext.getText(com.android.internal.R.string.roamingText10).toString());
328f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
329f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
330f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        case 11:
331f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            ret = new EriDisplayInformation(
332f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    roamInd,
333f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_ICON_MODE_NORMAL,
334f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    mContext.getText(com.android.internal.R.string.roamingText11).toString());
335f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
336f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
337f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        case 12:
338f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            ret = new EriDisplayInformation(
339f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    roamInd,
340f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    EriInfo.ROAMING_ICON_MODE_NORMAL,
341f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    mContext.getText(com.android.internal.R.string.roamingText12).toString());
342f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
343f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
344f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        // Handling the non standard Enhanced Roaming Indicator (roamInd > 63)
345f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        default:
346f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            if (!isEriFileLoaded) {
347f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                // ERI file NOT loaded
348f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                Log.d(LOG_TAG, "ERI File not loaded");
349f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                if(defRoamInd > 2) {
350f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    Log.d(LOG_TAG, "ERI defRoamInd > 2 ...flashing");
351f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    ret = new EriDisplayInformation(
352f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                            EriInfo.ROAMING_INDICATOR_FLASH,
353f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                            EriInfo.ROAMING_ICON_MODE_FLASH,
354f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                            mContext.getText(com.android.internal
355f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                                            .R.string.roamingText2).toString());
356f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                } else {
357f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    Log.d(LOG_TAG, "ERI defRoamInd <= 2");
358f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    switch (defRoamInd) {
359f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    case EriInfo.ROAMING_INDICATOR_ON:
360f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                        ret = new EriDisplayInformation(
361f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                EriInfo.ROAMING_INDICATOR_ON,
362f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                EriInfo.ROAMING_ICON_MODE_NORMAL,
363f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                mContext.getText(com.android.internal
364f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                                            .R.string.roamingText0).toString());
365f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                        break;
366f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
367f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    case EriInfo.ROAMING_INDICATOR_OFF:
368f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                        ret = new EriDisplayInformation(
369f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                EriInfo.ROAMING_INDICATOR_OFF,
370f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                EriInfo.ROAMING_ICON_MODE_NORMAL,
371f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                mContext.getText(com.android.internal
372f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                                            .R.string.roamingText1).toString());
373f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                        break;
374f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
375f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    case EriInfo.ROAMING_INDICATOR_FLASH:
376f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                        ret = new EriDisplayInformation(
377f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                EriInfo.ROAMING_INDICATOR_FLASH,
378f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                EriInfo.ROAMING_ICON_MODE_FLASH,
379f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                mContext.getText(com.android.internal
380f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                                            .R.string.roamingText2).toString());
381f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                        break;
382f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
383f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    default:
384f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                        ret = new EriDisplayInformation(-1, -1, "ERI text");
385f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    }
386f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                }
387f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            } else {
388f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                // ERI file loaded
389f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                Log.d(LOG_TAG, "ERI File loaded");
390f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                EriInfo eriInfo = getEriInfo(roamInd);
391f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                EriInfo defEriInfo = getEriInfo(defRoamInd);
392f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                if (eriInfo == null) {
393f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    Log.d(LOG_TAG, "ERI roamInd " + roamInd
394f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                            + " not found in ERI file ...using defRoamInd " + defRoamInd);
395f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    if(defEriInfo == null) {
396f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                        Log.e(LOG_TAG, "ERI defRoamInd " + defRoamInd
397f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                + " not found in ERI file ...on");
398f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                        ret = new EriDisplayInformation(
399f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                EriInfo.ROAMING_INDICATOR_ON,
400f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                EriInfo.ROAMING_ICON_MODE_NORMAL,
401f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                mContext.getText(com.android.internal
402f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                                             .R.string.roamingText0).toString());
403f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
404f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    } else {
405f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                        Log.d(LOG_TAG, "ERI defRoamInd " + defRoamInd + " found in ERI file");
406f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                        ret = new EriDisplayInformation(
407f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                defEriInfo.mIconIndex,
408f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                defEriInfo.mIconMode,
409f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                                defEriInfo.mEriText);
410f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    }
411f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                } else {
412f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    Log.d(LOG_TAG, "ERI roamInd " + roamInd + " found in ERI file");
413f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                    ret = new EriDisplayInformation(
414f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                            eriInfo.mIconIndex,
415f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                            eriInfo.mIconMode,
416f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                            eriInfo.mEriText);
417f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville                }
418f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            }
419f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville            break;
420f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        }
421f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        Log.d(LOG_TAG, "Displaying ERI " + ret.toString());
422f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        return ret;
423f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville    }
424f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
425f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville    public int getCdmaEriIconIndex(int roamInd, int defRoamInd){
426f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        return getEriDisplayInformation(roamInd, defRoamInd).mEriIconIndex;
427f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville    }
428f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
429f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville    public int getCdmaEriIconMode(int roamInd, int defRoamInd){
430f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        return getEriDisplayInformation(roamInd, defRoamInd).mEriIconMode;
431f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville    }
432f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville
433f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville    public String getCdmaEriText(int roamInd, int defRoamInd){
434f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville        return getEriDisplayInformation(roamInd, defRoamInd).mEriIconText;
435f315238a2b07c7e84f6ade800e504f520d262e66Wink Saville    }
436e9b06d754af03faf27012fbed1e7559ec1ba7c79Wink Saville}
437