Preface
Welcome to share and recommend useful code segments ~~
Statement
You are welcome to repost, but please keep the original source of the article:
CSDN:Http://www.csdn.net
O Mo Li in the rainy season:Http://blog.csdn.net/luckkof
Body
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 is
Note:
If there is no voicemail number provisioning function, the voicemail-conf.xml file is optional, otherwise it must be available.
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, go 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 the GB3 version, go to build \ target \ product \ xxx. in mk (xxx is the project name), add the statement PRODUCT_COPY_FILES + = mediate/frameworks/telephony/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. java (
Versions earlier than JB3: frameworks \ base \ telephony \ java \ com \ android \ internal \ telephony \ gsm
JB3, JB5: frameworks \ opt \ telephony \ src \ java \ com \ android \ internal \ telephony \ gsm)
In the private setVoiceMailByCountry (String spn) function, modify the statement if (mVmConfig. containsCarrier (spn)
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. java
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 GSMPhone. java (
Versions earlier than JB3: frameworks \ base \ telephony \ java \ com \ android \ internal \ telephony \ gsm
In the case EVENT_SIM_RECORDS_LOADED statement in the handleMessage function of JB3, JB5: frameworks \ opt \ telephony \ src \ java \ com \ android \ internal \ telephony \ gsm): Set the statement if (imsi! = Null & imsiFromSIM! = Null &&! ImsiFromSIM. equals (imsi ))
{
...
}
Change
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. get ())). 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)
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;
}