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;