Android preset default voicemail number implementation

Source: Internet
Author: User

Some SIM cards are not preset with the VoiceMail number at the factory, but the operator requires that the preset VM number be read from the mobile phone according to PLMN. This section describes how to preset VM number in xml format and how to allow users to modify and remember their choices. The priority of VM number is: SIM card reading> User Settings> xml preset. When you modify the voice mail number, the SIM card is preferentially stored. If the SIM card storage fails, it is stored in the mobile phone in the unit of IMSI.

1. Support VM number preset in XML format, file name: voicemail-conf.xml
The file content format isCopy codeThe Code is as follows: <? Xml version = '1. 0' encoding = 'utf-8'?>
<Voicemail>
<Voicemail numeric = "46000" carrier = "CMCC" vmnumber = "10086" vmtag = "CMCC voicemail"/>
</Voicemail>

2. File Location
File Location on mobile phone: system/etc
File Location in the project (GB, GB2): vendor \ mediatek \ etc
File Location in the project (ICS and later): mediatek \ source \ frameworks \ telephony \ etc
For versions of GB and GB2, you also need to build \ target \ product \ xxx. in mk (xxx is the project name), add the statement PRODUCT_COPY_FILES + = vendor/mediatek/etc/voicemail-conf.xml: system/etc/voicemail-conf.xml
For ICS and ICS2 versions, you also need to build \ target \ product \ common. mk, add statement PRODUCT_COPY_FILES + = mediate/source/frameworks/telephony/etc/voicemail-conf.xml: system/etc/voicemail-conf.xml
For Versions later than JB and JB2, you also need to build \ target \ product \ common. mk, add statement PRODUCT_COPY_FILES + = mediate/frameworks/base/telephony/etc/voicemail-conf.xml: system/etc/voicemail-conf.xml

3. the VM number in the SIM card takes precedence over the preset number.
Set SIMRecords. in java (frameworks \ base \ telephony \ java \ com \ android \ internal \ telephony \ gsm), the statement if (mVmConfig. containsCarrier (SPNs)
If (TextUtils. isEmpty (voiceMailTag) & TextUtils. isEmpty (voiceMailNum) & mVmConfig. containsCarrier (spn ))
4. After using the voicemail-conf.xml to preset the VM number, the end user can modify the VM number Method
1) Add the statement import android. text. TextUtils in SIMRecords. java;
2) Add a member variable boolean isSetByCountry = false in SIMRecords. java;
3) change the private setVoiceMailByCountry (String SPNs) function in SIMRecords. javaCopy codeThe Code is as follows: private void setVoiceMailByCountry (String spn ){
If (TextUtils. isEmpty (voiceMailTag) & TextUtils. isEmpty (voiceMailNum) & mVmConfig. containsCarrier (spn ))
{
// IsVoiceMailFixed = true; // comment out this statement so that you can modify it
IsSetByCountry = true; // Let the GsmPhone know that this is read from xml
VoiceMailNum = mVmConfig. getVoiceMailNumber (spn );
VoiceMailTag = mVmConfig. getVoiceMailTag (spn );
}

4) In the case EVENT_SIM_RECORDS_LOADED statement of the handleMessage function in GSMPhone. java (frameworks \ base \ telephony \ java \ com \ android \ internal \ telephony \ gsm), set the statement if (imsi! = Null & imsiFromSIM! = Null &&! ImsiFromSIM. equals (imsi ))
{
...
}
ChangeCopy codeThe Code is as follows: SharedPreferences sp = PreferenceManager. getdefasharsharedpreferences (getContext ());
// After the SIM card is changed in the corresponding card slot, whether to clear the user's VM number settings for the previous SIM card
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) set the GSMPhone. the statement editor in the private void storeVoiceMailNumber (String number) function in java. putString (VM_NUMBER + mySimId, number); modified to editor. putString (getSubscriberId (), number); // no longer uses the card slot as the unit for saving the VM number, but uses IMSI
6) set the GSMPhone. if (TextUtils. isEmpty (number) to if (TextUtils. isEmpty (number) | (SIMRecords) mIccRecords ). isSetByCountry) // If the SIM card is in
// No VM number or set through the voicemail-conf.xml, you should read the Preference to see if the user
// VM number has been set for this SIM card.
Modify the statement number = sp. getString (VM_NUMBER + mySimId, null)Copy codeThe Code is as follows: 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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.