MTK平台怎么修改双卡默认不同铃声?
你们有打patch么?啥平台啊
82平台是有两个patch的,P33和P38
72平台和82平台都需要,谢谢兄弟!
[DESCRIPTION]
合入patch:ALPS00658552 后铃声设置中可以分别设置sim1和sim2的铃声。
但sim1和sim2的默认铃声都是一样的,如何分开设置sim1,sim2的默认铃声。
[SOLUTION]
1,alps\build\target\product\core.mk:
设置系统属性“ro.config.ringtone_sim2”(原来的ro.config.ringtone给卡1用):
PRODUCT_PROPERTY_OVERRIDES := \
ro.config.notification_sound=Proxima.ogg \
ro.config.alarm_alert=Alarm_Classic.ogg \
ro.config.ringtone=Backroad.ogg\
ro.config.ringtone_sim2=Carina.ogg
2,frameworks/base/core/java/android/provider/Settings.java中:
1)添加卡2的铃声属性字段RINGTONE_SIM2,这个值与前面在core.mk中定义的属性的最后一个字段相同,如您定义为“ro.config.ringtone_sim2”,
则RINGTONE_SIM2为“RINGTONE_SIM2 = "ringtone_sim2",假设您定义的属性为“ro.config.ringtone_sim_id_2”
则对应的RINGTONE_SIM2="ringtone_sim_id_2",参考标有//add this line为添加的部分:
public static final String RINGTONE = "ringtone";
public static final String RINGTONE_SIM2 = "ringtone_sim2";//add this line
public static final Uri DEFAULT_RINGTONE_URI = getUriFor(RINGTONE);
public static final Uri DEFAULT_RINGTONE_SIM2_URI = getUriFor(RINGTONE_SIM2);//add this line
3,alps\frameworks\base\media\java\android\media\RintoneManager.java:
1),添加SIM2的type,参考//add this line为添加的部分:
public static final int TYPE_VIDEO_CALL = 8;
public static final int TYPE_SIP_CALL = 16;
public static final int TYPE_RINGTONE_SIM2 = 32;//add this line
public static final String KEY_DEFAULT_RINGTONE_SIM2 = "mtk_audioprofile_default_ringtone_sim2";//add this line
2) 返回获取的sim2的uri,参考//add this line为添加的部分:
public static Uri getDefaultRingtoneUri(Context context, int type) {
...
switch (type) {
case TYPE_RINGTONE:
uriString = Settings.System.getString(resolver, KEY_DEFAULT_RINGTONE);
break;
case TYPE_RINGTONE_SIM2://add this line
uriString = Settings.System.getString(resolver, KEY_DEFAULT_RINGTONE_SIM2);//add this line
break;//add this line
4,alps\frameworks\base\media\java\android\media\MediaScanner.java中:
1),添加读取到的卡2 的默认铃声相关定义:
private String mDefaultRingtoneSim2Filename;
private boolean mDefaultRingtoneSim2Set;
private static final String RINGTONE_SIM2_SET = "ringtone_sim2_set";
2),将core.mk中定义的sim2 铃声的名字读出来,参考//add this line为添加的部分:
private void setDefaultRingtoneFileNames() {
mDefaultRingtoneFilename = SystemProperties.get(DEFAULT_RINGTONE_PROPERTY_PREFIX
+ Settings.System.RINGTONE);
mDefaultRingtoneSim2Filename = SystemProperties.get(DEFAULT_RINGTONE_PROPERTY_PREFIX
+ Settings.System.RINGTONE_SIM2);//add this line
...
}
3),添加isSim2Ringtone来区别设置的是sim1还是sim2,然后将扫描到的文件名和上面读到的sim2默认铃声文件名对比,如果是sim2 的ringtone,则设置sim2默认值。参考注有"//add this line"或" //start modify"和"//end modify"包含的地方:
private Uri endFile(FileEntry entry, boolean ringtones, boolean notifications,
boolean alarms, boolean music, boolean podcasts){
boolean isSim2Ringtone = false; //add this line
.....
if (notifications &&((mWasEmptyPriorToScan && !mDefaultNotificationSet) ||
doesSettingEmpty(NOTIFICATION_SET))) {
....
//start modify
} else if (ringtones && ((mWasEmptyPriorToScan && (!mDefaultRingtoneSet||!mDefaultRingtoneSim2Set)) ||
doesSettingEmpty(RINGTONE_SET)||doesSettingEmpty(RINGTONE_SIM2_SET))) {
if (TextUtils.isEmpty(mDefaultRingtoneFilename) ||
doesPathHaveFilename(entry.mPath, mDefaultRingtoneFilename)) {
needToSetSettings = true;
/// M: Adds log to debug setting ringtones.
Xlog.v(TAG, "endFile: needToSetRingtone=true.");
}
else if(TextUtils.isEmpty(mDefaultRingtoneSim2Filename) ||
doesPathHaveFilename(entry.mPath, mDefaultRingtoneSim2Filename))
{
needToSetSettings = true;
isSim2Ringtone = true;
Xlog.v(TAG, "endFile: needToSetRingtone=true.sim2 default ringtone");
}
//end modify
} else if (alarms && ((mWasEmptyPriorToScan && !mDefaultAlarmSet) ||
doesSettingEmpty(ALARM_SET))) {
...
}
...
if(needToSetSettings) {
if (notifications && doesSettingEmpty(NOTIFICATION_SET)) {
.....
//start modify
} else if (ringtones && (doesSettingEmpty(RINGTONE_SET)||doesSettingEmpty(RINGTONE_SIM2_SET)))
if(!isSim2Ringtone)
{
setSettingIfNotSet(Settings.System.RINGTONE, tableUri, rowId);
setSettingIfNotSet(Settings.System.VIDEO_CALL, tableUri, rowId);
setSettingIfNotSet(Settings.System.SIP_CALL, tableUri, rowId);
setProfileSettings(RingtoneManager.TYPE_RINGTONE, tableUri, rowId);
setProfileSettings(RingtoneManager.TYPE_VIDEO_CALL, tableUri, rowId);
setProfileSettings(RingtoneManager.TYPE_SIP_CALL, tableUri, rowId);
mDefaultRingtoneSet = true;
setSettingFlag(RINGTONE_SET);
Xlog.v(TAG, "endFile: set ringtone. uri=" + tableUri + ", rowId=" + rowId);
}
else
{
setSettingIfNotSet(SSettings.System.RINGTONE_SIM2, tableUri, rowId);
setProfileSettings(RingtoneManager.TYPE_RINGTONE_SIM2, tableUri, rowId);
mDefaultRingtoneSim2Set = true;
setSettingFlag(RINGTONE_SIM2_SET);
Xlog.v(TAG, "endFile: set sim2 ringtone. uri=" + tableUri + ", rowId=" + rowId);
}
//end modify
}else if (alarms && doesSettingEmpty(ALARM_SET)) {
....
}
4),添加设置sim2铃声,参考//start modify 和//end modify的地方:
private void setProfileSettings(int type, Uri uri, long rowId) {
if(type == RingtoneManager.TYPE_NOTIFICATION) {
setSettingIfNotSet(RingtoneManager.KEY_DEFAULT_NOTIFICATION, uri, rowId);
} else if(type == RingtoneManager.TYPE_RINGTONE) {
setSettingIfNotSet(RingtoneManager.KEY_DEFAULT_RINGTONE, uri, rowId);
//start modify
} else if(type ==RingtoneManager.TYPE_RINGTONE_SIM2){
setSettingIfNotSet(RingtoneManager.KEY_DEFAULT_RINGTONE_SIM2, uri, rowId);
//end modify
} else if(type == RingtoneManager.TYPE_VIDEO_CALL) {
setSettingIfNotSet(RingtoneManager.KEY_DEFAULT_VIDEO_CALL, uri, rowId);
} else if(type == RingtoneManager.TYPE_SIP_CALL) {
setSettingIfNotSet(RingtoneManager.KEY_DEFAULT_SIP_CALL, uri, rowId);
} else if(type == RingtoneManager.TYPE_ALARM) {
setSettingIfNotSet(RingtoneManager.KEY_DEFAULT_ALARM, uri, rowId);
}
}
5 alps\mediatek\frameworks\base\media\audio\java\com\mediatek\audioprofile\AudioProfileService.java:
1)定义给sim2 ringtone用的index,同时修改ringtone type的个数,由原来的4改成5,参考注有“//modify this line”和“//add this line”的地方
// mDefaultRingtone index
private static final int DEFAULT_RINGTONE_TYPE_CONUT = 5;//modify this line
private static final int DEFAULT_RINGER_INDEX = ProfileSettings.ringer_stream.ordinal();
private static final int DEFAULT_NOTIFICATION_INDEX = ProfileSettings.notification_stream.ordinal();
private static final int DEFAULT_VIDEOCALL_INDEX = ProfileSettings.videocall_Stream.ordinal();
private static final int DEFAULT_SIPCALL_INDEX = ProfileSettings.sipcall_Stream.ordinal();
private static final int DEFAULT_RINGER_SIM2_INDEX = ProfileSettings.ringer_sim2_stream.ordinal();//add this line
2)情景模式读铃声默认值时,添加读取sim2的默认值,参考//start modify和//end modify之间的修改:
private void readDefaultRingtones() {
....
// mDefaultRingtone[3] sip ringtone
uriString = Settings.System.getString(mContentResolver, AudioProfileManager.KEY_DEFAULT_SIP_CALL);
uri = (uriString == null ? null : Uri.parse(uriString));
mDefaultRingtone.set(DEFAULT_SIPCALL_INDEX, uri);
//start modify
// mDefaultRingtone[4] vioce ringtone sim2
uriString = Settings.System.getString(mContentResolver, AudioProfileManager.KEY_DEFAULT_RINGTONE_SIM2);
uri = (uriString == null ? null : Uri.parse(uriString));
mDefaultRingtone.set(DEFAULT_RINGER_SIM2_INDEX , uri);
//end modify
3)
import android.provider.Telephony.SIMInfo;
private void readPersistedSettings(String profileKey, long simId) {
...
//start modify
Uri voiceCallUri;
int slotId = SIMInfo.getSlotById(mContext, simId);//add this line
if(slotId ==1)
voiceCallUri = getPersistedValue(name, initValues,mDefaultRingtone.get(DEFAULT_RINGER_SIM2_INDEX));
else
voiceCallUri = getPersistedValue(name, initValues,mDefaultRingtone.get(DEFAULT_RINGER_INDEX));
}
//end modify
name = AudioProfileManager.getStreamUriKey(profileKey, AudioProfileManager.TYPE_NOTIFICATION);
Uri notificationUri = getPersistedValue(name, initValues,
mDefaultRingtone.get(DEFAULT_NOTIFICATION_INDEX));
...
}
6,alps\mediatek\frameworks\base\media\audio\java\com\mediatek\audioprofile\AudioProfileManager.java:
1) public static final String KEY_DEFAULT_RINGTONE_SIM2 = "mtk_audioprofile_default_ringtone_sim2";//add this line
2) public enum ProfileSettings {
ringer_stream, notification_stream, videocall_Stream, sipcall_Stream,ringer_sim2_stream, //add this line
ringer_volume, notification_volume, alarm_volume,
vibration_enabled, dtmftone_enabled, soundeffect_enbled, hapticfeedback_enabled,
lockscreensound_enabled
}
明白了,谢谢。不过前提还是要先打ALPS00658552 这个patch。
智能机没有干过,帮顶一下
智能机没有干过,帮顶一下
智能机没有干过,帮顶一下
收藏下。
收藏下。
小编,这个path 怎么打入啊。我现在的系统还部分卡1
卡2,的,我想问问那,怎么先分了卡1,卡2 啊