Android sets a song in the music player as a ringtone, And the setting does not work.

Source: Internet
Author: User

Android sets a song in the music player as a ringtone, And the setting does not work.
AudioProfile, scene mode, multi-card ringtone setting
The system enables Multi_ringtone_support. Choose "Music"> "song list"> "Long-press a song" and choose "set as the ringtone". The message is displayed, but the set scene mode is displayed. The default ringtone is displayed. After a call, the ringtone is also the default ringtone.
Modify:
AudioProfileService. java
MRingtoneObserver = new ContentObserver (new Handler ()
Case GENERAL:
Case OUTDOOR:
If (mExt. shouldsyncgeneralringtonututdoor ()){
// If ringtone has been changed and the active profile is general
// Or outdoor profile, synchronize the current system ringtone
// To both profiles.
If (isPassiveChange &&(! MResetFlag )){
String generalKey = mPredefinedKeys. get (Scenario. GENERAL. ordinal ());
String outdoorKey = mPredefinedKeys. get (Scenario. OUTDOOR. ordinal ());
GetProfileState (generalKey, mSimId). mRingerStream = systemUri;
GetProfileState (outdoorKey, mSimId). mRingerStream = systemUri;
PersistRingtoneUriToDatabase (generalKey, AudioProfileManager. TYPE_RINGTONE, mSimId, systemUri );
PersistRingtoneUriToDatabase (outdoorKey, AudioProfileManager. TYPE_RINGTONE, mSimId, systemUri );
Log. d (TAG, "Ringtone changed by other app in non-silent"
+ "Profile, synchronize to active profile: new uri =" + systemUri );
} Else {
Log. d (TAG, "Ringtone changed by itself, do nothing! ");
}
Break;
}
As shown in the following figure:
Case GENERAL:
Case OUTDOOR:
If (mExt. shouldsyncgeneralringtonututdoor ()){
// If ringtone has been changed and the active profile is general
// Or outdoor profile, synchronize the current system ringtone
// To both profiles.
If (isPassiveChange &&(! MResetFlag )){
// M: for setringtoneformprofile or from 3rd app
If (FeatureOption. MTK_MULTISIM_RINGTONE_SUPPORT ){
// Add to get selected SIM id
List SimList = SIMInfo. getInsertedSIMList (mContext );
Int simNum = simList. size ();
Log. d (TAG, "simList. size () =" + simNum );
Long simId =-1;
For (int I = 0; I <simNum; I ++ ){
SimId = simList. get (I). mSimId;

String generalKey = mPredefinedKeys. get (Scenario. GENERAL. ordinal ());
String outdoorKey = mPredefinedKeys. get (Scenario. OUTDOOR. ordinal ());
GetProfileState (generalKey, simId). mRingerStream = systemUri;
GetProfileState (outdoorKey, simId). mRingerStream = systemUri;
PersistRingtoneUriToDatabase (generalKey, AudioProfileManager. TYPE_RINGTONE, simId, systemUri );
PersistRingtoneUriToDatabase (outdoorKey, AudioProfileManager. TYPE_RINGTONE, simId, systemUri );
Log. d (TAG, "Ringtone changed by other app in non-silent"
+ "Profile, synchronize to active profile: new uri =" + systemUri );
Log. d (TAG, "mRingtoneObserver simId" + simId );
}
} Else {
String generalKey = mPredefinedKeys. get (Scenario. GENERAL. ordinal ());
String outdoorKey = mPredefinedKeys. get (Scenario. OUTDOOR. ordinal ());
GetProfileState (generalKey, mSimId). mRingerStream = systemUri;
GetProfileState (outdoorKey, mSimId). mRingerStream = systemUri;
PersistRingtoneUriToDatabase (generalKey, AudioProfileManager. TYPE_RINGTONE, mSimId, systemUri );
PersistRingtoneUriToDatabase (outdoorKey, AudioProfileManager. TYPE_RINGTONE, mSimId, systemUri );
Log. d (TAG, "Ringtone changed by other app in non-silent"
+ "Profile, synchronize to active profile: new uri =" + systemUri );
}

} Else {
Log. d (TAG, "Ringtone changed by itself, do nothing! ");
}
Break;
}
Similarly, for custom case
Case CUSTOM:
If (isPassiveChange &&(! MResetFlag )){
ActiveState. mRingerStream = systemUri;
PersistRingtoneUriToDatabase (mActiveProfileKey, AudioProfileManager. TYPE_RINGTONE, mSimId, systemUri );
Log. d (...);
} Else {
Log. d (...);
}
Break;
Change,
Case CUSTOM:
If (isPassiveChange &&(! MResetFlag )){
If (FeatureOption. MTK_MULTISIM_RINGTONE_SUPPORT ){
// Add to get selected SIM id
List SimList = SIMInfo. getInsertedSIMList (mContext );
Int simNum = simList. size ();
Log. d (TAG, "simList. size () =" + simNum );
Long simId =-1;
For (int I = 0; I <simNum; I ++ ){
SimId = simList. get (I). mSimId;
PersistRingtoneUriToDatabase (mActiveProfileKey, AudioProfileManager. TYPE_RINGTONE, simId, systemUri );
}
} Else {
ActiveState. mRingerStream = systemUri;
PersistRingtoneUriToDatabase (mActiveProfileKey, AudioProfileManager. TYPE_RINGTONE, mSimId, systemUri );
Log. d (...);
}
} Else {
Log. d (...);
}
Break;

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.