android 在音樂播放器中設定一首歌曲為來電鈴聲,設定不起作用

來源:互聯網
上載者:User

標籤:android   io   ar   java   for   sp   on   log   cti   

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;

android 在音樂播放器中設定一首歌曲為來電鈴聲,設定不起作用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.