Android之來電鈴聲設定

來源:互聯網
上載者:User

標籤:

                                             Android之來電鈴聲設定

 

從檔案管理工具中設定一首歌曲為來電鈴聲鈴聲,進入撥號盤設定中點擊提示音和震動,來電鈴聲就會變成預設鈴聲

從檔案管理工具中設定一首歌曲為來電鈴聲鈴聲,進入撥號盤設定中點擊提示音和震動,來電鈴聲就會變成預設鈴聲
歌曲是SD卡中的
1.進入檔案管理工具
2.從SD卡中設定一首歌曲為來電鈴聲
3.進入settings》》提示音和通知》》手機鈴聲,查看來電鈴聲的歌曲是剛剛設定的外部歌曲
4.進入撥號盤設定中,點擊提示音和震動
5.返回settings》》提示音和通知》》手機鈴聲,查看來電鈴聲
來電鈴聲的歌曲應該還是剛剛設定的外部歌曲
來電鈴聲變回了預設鈴聲

首先分享一下一些常用的命令:

3.在cmd終端下進行activity的查看命令"START u0"
adb logcat | findstr /C:"START u0"
adb shell logcat | grep "START u0"
logcat | findstr /C:"BDC-Calling"
adb logcat -s AndroidRuntime
adb logcat -s sound_trigger_hw_default
adb logcat | findstr Ringer
adb logcat -s System.err
adb shell cat /data/system/audio_profile/0/settings.ini
/storage/emulated/0/liunian/
adb pull /data/data/com.android.providers.telephony/
adb pull /data/data/com.android.providers.settings/
adb pull /data/data/com.android.providers.media/
adb logcat -s SettingsInterface | findstr audioprofile

adb logcat -s AudioProfileService | findstr updateRintone
在調試裝置的時候。想要對檔案進行讀寫
於是使用adb remount
出現提示,請使用 “adb disable-verity”
於是使用adb disable-verity 的命令

這些命令會協助我們快速分析問題

接著說:

這個問題是與sim 卡有關的,必須插sim 卡才可以,因為需要獲得soltId

subId相當於_id,類似於1,2,3之類的id保證唯一性

slotId與卡槽有關係,sim卡在卡槽1裡slotId==0

sim卡在卡槽2裡slotId==1

當手機裡不插sim卡時,slotId==-1

在MTK67xx/packages/apps/Settings/src/com/mediatek/audioprofile/DefaultRingtonePreference.java中

 

if (FeatureOption.MTK_MULTISIM_RINGTONE_SUPPORT && simNum == SINGLE_SIMCARD) {

int subId = SubscriptionManager.from(getContext()).getActiveSubscriptionIdList()[0];

 

setSimId(subId);

//setSimId(1);

}

 

if (isNoNeedSIMSelector() || simNum <= SINGLE_SIMCARD) {

super.onClick();

 

}

}

 

修改為:

if (FeatureOption.MTK_MULTISIM_RINGTONE_SUPPORT && simNum == SINGLE_SIMCARD) {

int subId = SubscriptionManager.from(getContext()).getActiveSubscriptionIdList()[0];

 

//xxx begin

int slotId = SubscriptionManager.getSlotId(subId);

 

if(slotId == 1){

subId = 2;

 

}else if(slotId == 0){

subId = 1;

 

}

//xxx end

setSimId(subId);

 

//setSimId(1);

}

在MTK6735/packages/apps/Settings/src/com/mediatek/audioprofile/Editprofile.java中

if (requestCode == REQUEST_CODE) {

if (resultCode == Activity.RESULT_OK) {

mSimId = data.getLongExtra(PhoneConstants.SUBSCRIPTION_KEY,

SubscriptionManager.INVALID_SUBSCRIPTION_ID);

setRingtoneSIMId(mSimId);

}

Log.v("@M_" + TAG, "Select SIM id = " + mSimId);

 

修改為:

if (requestCode == REQUEST_CODE) {

 

if (resultCode == Activity.RESULT_OK) {

mSimId = data.getLongExtra(PhoneConstants.SUBSCRIPTION_KEY,

 

SubscriptionManager.INVALID_SUBSCRIPTION_ID);

//xxx begin

 

int slotId = SubscriptionManager.getSlotId((int) mSimId);

if(slotId == 1){

 

mSimId = 2;

}else if(slotId == 0){

 

mSimId = 1;

}

 

//xxxend

setRingtoneSIMId(mSimId);

 

}

Log.v("@M_" + TAG, "Select SIM id = " + mSimId);

 

這個兩檔案的修改的作用是在sd中的音樂設定為來電鈴聲後

進到設定中進提示音進手機鈴聲可以看到選擇的正是自己設定的那首音樂

但是來電的時候響起的還是預設鈴聲

還有一個檔案要修改

在MTK6753_M_Xxx/packages/services/Telecomm/src/com/android/server/telecom/Ringer.java

PhoneAccount account = tm.getPhoneAccount(phoneAccountHandle);

if (account != null) {

 

subId = tem.getSubIdForPhoneAccount(account);

}

 

} catch(Exception e) {

e.printStackTrace();

 

Log.d(this, "getSubIdForPhoneAccount error: " + e.toString());

}

 

}

}

 

AudioProfileManager audioProfileMgr = (AudioProfileManager) mContext

.getSystemService(Context.AUDIO_PROFILE_SERVICE);

 

Uri ringtoneUri = audioProfileMgr.getRingtoneUri(audioProfileMgr.getActiveProfileKey() , AudioProfileManager.TYPE_RINGTONE, subId);

修改成

}

 

//xxx begin

int slotId = SubscriptionManager.getSlotId(subId);

if(slotId == 1){

 

subId = 2;

}else if(slotId == 0){

 

subId = 1;

}

//xxx end

AudioProfileManager audioProfileMgr = (AudioProfileManager) mContext .getSystemService(Context.AUDIO_PROFILE_SERVICE);

 

Uri ringtoneUri = audioProfileMgr.getRingtoneUri(audioProfileMgr.getActiveProfileKey() , AudioProfileManager.TYPE_RINGTONE, subId);

這樣來電鈴聲就為sd卡中設定的音樂了

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.