1、支持以XML的方式预置VM number,文件名为:voicemail-conf.xml
文件的内容格式为
复制代码 代码如下:
2、关于文件的位置
文件在手机中的位置:system/etc
文件在工程中的位置(GB, GB2): vendor\mediatek\etc
文件在工程中的位置(ICS及以后): mediatek\source\frameworks\telephony\etc
对于GB、GB2的版本,还需要在在build\target\product\xxx.mk (xxx为工程名)中,添加语句PRODUCT_COPY_FILES += vendor/mediatek/etc/voicemail-conf.xml:system/etc/voicemail-conf.xml
对于ICS及ICS2的版本,还需要在build\target\product\common.mk中,添加语句PRODUCT_COPY_FILES += mediate/source/frameworks/telephony/etc/voicemail-conf.xml:system/etc/voicemail-conf.xml
对于JB及JB2以后的版本,还需要在build\target\product\common.mk中,添加语句PRODUCT_COPY_FILES += mediate/frameworks/base/telephony/etc/voicemail-conf.xml:system/etc/voicemail-conf.xml
3、使SIM卡中的VM number优先于预置号码的方法
将SIMRecords.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm)中的函数private setVoiceMailByCountry(String spn)中的语句if (mVmConfig.containsCarrier(spn))修改为
if (TextUtils.isEmpty(voiceMailTag) && TextUtils.isEmpty(voiceMailNum) && mVmConfig.containsCarrier(spn))
4、在使用了voicemail-conf.xml来预置VM number后,使终端用户可以修改VM number的方法
1) 在SIMRecords.java中添加语句import android.text.TextUtils;
2) 在SIMRecords.java中添加一个成员变量boolean isSetByCountry = false;
3) 将SIMRecords.java中的函数private setVoiceMailByCountry(String spn)修改为
复制代码 代码如下:
private void setVoiceMailByCountry(String spn) {
if (TextUtils.isEmpty(voiceMailTag) && TextUtils.isEmpty(voiceMailNum) && mVmConfig.containsCarrier(spn))
{
// isVoiceMailFixed = true; //注释掉此语句以让用户能够修改
isSetByCountry = true; //让GsmPhone知道这是从xml中读取的
voiceMailNum = mVmConfig.getVoiceMailNumber(spn);
voiceMailTag = mVmConfig.getVoiceMailTag(spn);
}
4) 在GSMPhone.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm)中的函数handleMessage中的语句case EVENT_SIM_RECORDS_LOADED:中将语句 if (imsi != null && imsiFromSIM != null && !imsiFromSIM.equals(imsi))
{
…
}
修改为
复制代码 代码如下:
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
// 当相应卡槽更换SIM卡后,是否清除用户对之前SIM卡的VM number设置
boolean clear_if_change_sim = sp.getBoolean(“clear_if_change”, false);
if (clear_if_change_sim && imsi != null && imsiFromSIM != null && !imsiFromSIM.equals(imsi)){
//storeVoiceMailNumber(null);
Log.d(LOG_TAT, “reset vm number because sim changed”);
SharedPreferences.Editor editor = sp.edit();
editor.remove(getVmSimImsi());
editor.apply();
setVmSimImsi(null);
}
5) 将GSMPhone.java中的函数private void storeVoiceMailNumber(String number)中的语句editor.putString(VM_NUMBER+mySimId, number);修改为editor.putString(getSubscriberId(), number); //不再使用卡槽作为保存VM number的单位,而使用IMSI
6) 将GSMPhone.java中的函数public String getVoiceMailNumber()中的语句if (TextUtils.isEmpty(number))修改为 if (TextUtils.isEmpty(number) || ((SIMRecords)mIccRecords).isSetByCountry) //如果SIM卡中
//无VM number或是通过voicemail-conf.xml来设置的,则应该读取一下Preference,看是否用户
//对此SIM卡设置过VM number。
并且将语句number = sp.getString(VM_NUMBER+mySimId, null);修改为
复制代码 代码如下:
Log.d(LOG_TAG, vm num from simRecords, num= “+number+” is from factory= “+ ((SIMRecords)mIccRecords).isSetbyCountry);
String temp = sp.getString(getSubscriberId(), null);
if (temp != null)
{
Log.d(LOG_TAG, “replace vm num with user defined, num= “+temp);
number = temp;
}