首页 > 代码库 > android 在音乐播放器中设置一首歌曲为来电铃声,设置不起作用
android 在音乐播放器中设置一首歌曲为来电铃声,设置不起作用
AudioProfile,情景模式,多卡设置铃声
系统开启Multi_ringtone_support。进入菜单--音乐--歌曲列表--长按一首歌曲选择设为手机铃声,提示已成功设置,但是进入设置中情景模式查看,仍然是默认铃声。打电话后铃声还为默认铃声。
修改:
AudioProfileService.java
mRingtoneObserver = new ContentObserver(new Handler())函数里面的
case GENERAL:
case OUTDOOR:
if (mExt.shouldSyncGeneralRingtoneToOutdoor()) {
// 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;
}
改为如下的样子
case GENERAL:
case OUTDOOR:
if (mExt.shouldSyncGeneralRingtoneToOutdoor()) {
// 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<SIMInfo> 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;
}
同样的,对于custom case 也要处理
Case CUSTOM:
if (isPassiveChange && (!mResetFlag )){
activeState.mRingerStream = systemUri;
persistRingtoneUriToDatabase(mActiveProfileKey,AudioProfileManager.TYPE_RINGTONE,mSimId,systemUri);
Log.d(…);
} else {
Log.d(…);
}
break;
改为,
Case CUSTOM:
if (isPassiveChange && (!mResetFlag )){
if (FeatureOption.MTK_MULTISIM_RINGTONE_SUPPORT){
// add to get selected SIM id
List<SIMInfo> 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;
系统开启Multi_ringtone_support。进入菜单--音乐--歌曲列表--长按一首歌曲选择设为手机铃声,提示已成功设置,但是进入设置中情景模式查看,仍然是默认铃声。打电话后铃声还为默认铃声。
修改:
AudioProfileService.java
mRingtoneObserver = new ContentObserver(new Handler())函数里面的
case GENERAL:
case OUTDOOR:
if (mExt.shouldSyncGeneralRingtoneToOutdoor()) {
// 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;
}
改为如下的样子
case GENERAL:
case OUTDOOR:
if (mExt.shouldSyncGeneralRingtoneToOutdoor()) {
// 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<SIMInfo> 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;
}
同样的,对于custom case 也要处理
Case CUSTOM:
if (isPassiveChange && (!mResetFlag )){
activeState.mRingerStream = systemUri;
persistRingtoneUriToDatabase(mActiveProfileKey,AudioProfileManager.TYPE_RINGTONE,mSimId,systemUri);
Log.d(…);
} else {
Log.d(…);
}
break;
改为,
Case CUSTOM:
if (isPassiveChange && (!mResetFlag )){
if (FeatureOption.MTK_MULTISIM_RINGTONE_SUPPORT){
// add to get selected SIM id
List<SIMInfo> 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;
android 在音乐播放器中设置一首歌曲为来电铃声,设置不起作用
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。