Android Preset default voicemail number specifically implemented _android

Source: Internet
Author: User
Some SIM cards do not have a preset voicemail number at the factory, but the operator also requires the ability to adaptively read the preset VM number from the phone according to PLMN. This article describes how to preset VM number in XML, and how to allow users to modify and remember the user's choices. VM number uses a priority of: SIM card read > user settings >xml preset. When the user modifies voice mail number, the SIM card is first stored. If the SIM card store fails, it is stored in IMSI to the phone.

1, support in the way of XML preset VM number, file name is: Voicemail-conf.xml
The contents of the file are formatted as
Copy Code code as follows:

<?xml version= ' 1.0 ' encoding= ' utf-8 '?>
<voicemail>
<voicemail numeric= "46000" carrier= "CMCC" vmnumber= "10086" vmtag= "CMCC Voicemail"/>
</voicemail>

2, about the location of the file
The location of the file on the phone: system/etc
The location of the file in the project (GB, GB2): vendor\mediatek\etc
Location of the document in the project (ICS and beyond): Mediatek\source\frameworks\telephony\etc
For GB, GB2 versions, you also need to add statements product_copy_files + = vendor/mediatek/etc/in build\target\product\xxx.mk (XXX is the project name) Voicemail-conf.xml:system/etc/voicemail-conf.xml
For ICS and ICS2 versions, you also need to add statements product_copy_files + = mediate/source/frameworks/telephony/in build\target\product\common.mk Etc/voicemail-conf.xml:system/etc/voicemail-conf.xml
For later versions of JB and JB2, it is also necessary to add statements product_copy_files + = mediate/frameworks/base/telephony/in build\target\product\common.mk Etc/voicemail-conf.xml:system/etc/voicemail-conf.xml

3, so that the number of VM in the SIM card prior to the preset numbers method
To Simrecords.java (FRAMEWORKS\BASE\TELEPHONY\JAVA\COM\ANDROID\INTERNAL\TELEPHONY\GSM) functions in private The statement if (Mvmconfig.containscarrier (SPN)) in the Setvoicemailbycountry (String SPN) is modified to
if (Textutils.isempty (Voicemailtag) && textutils.isempty (voicemailnum) && Mvmconfig.containscarrier (SPN))
4, after using the Voicemail-conf.xml to preset VM number, so that end users can modify the VM number method
1 Add the Statement import android.text.TextUtils in the Simrecords.java;
2 Add a member variable in Simrecords.java boolean issetbycountry = false;
3) The function private setvoicemailbycountry (String SPN) in Simrecords.java is modified to
Copy Code code 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 the user can modify the
Issetbycountry = true; Let Gsmphone know that this is read from XML
Voicemailnum = Mvmconfig.getvoicemailnumber (SPN);
Voicemailtag = Mvmconfig.getvoicemailtag (SPN);
}

4 The statement case in the function handlemessage in Gsmphone.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm) Event_sim_records_loaded: The statement if (IMSI!= null && imsifromsim!= null &&!imsifromsim.equals (IMSI))
{
...
}
Amended to
Copy Code code as follows:

Sharedpreferences sp = preferencemanager.getdefaultsharedpreferences (GetContext ());
Whether to clear the user's VM number setting for the previous SIM card after the corresponding slot has been replaced by the 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 The statements in the Gsmphone.java function in private void Storevoicemailnumber (String number) editor.putstring (vm_number+mysimid, number ); modified to Editor.putstring (Getsubscriberid (), number); Instead of using a slot as a unit for saving VM number, use the IMSI
6) Modify the statement if (Textutils.isempty (number) in the function public String getvoicemailnumber () in Gsmphone.java to if (Textutils.isempty ( Number) | | ((simrecords) miccrecords). Issetbycountry)//If the SIM card
No VM number or set by Voicemail-conf.xml, you should read the preference to see if the user
VM number has been set on this SIM card.
and the statement number = sp.getstring (Vm_number+mysimid, NULL);
Copy Code code as follows:

LOG.D (log_tag, VM num from Simrecords, num= "+number+" are 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;
}
Related Article

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.