情景模式中是一个叫做Ringtone & notificationsWHY两个宏
FeatureOption.WT_CUSTOMER_STREAM_RING_VOLUME 和 FeatureOption.WT_CUSTOMER_STREAM_NOTIFICATION_VOLUME,
这两个在软件 情景模式中是一个吧 叫做Ringtone & notifications。为什么两个宏? 而且注意下,不要把这两个的音量配置成不一样的,要不会有问题。
例如 RING 音量配置的是 7 NOTIFICATION 的音量配置的是3,那么你烧软件或者回复出厂设置的时候,情景模式中这一项音量就是7, 但是在情景模式中有个恢复默认的按钮,点了之后这一项就是3了。会报bug。
看了下在RingerVolumePreference.java文件下
private static final int[] SEEKBAR_ID = new int[] {
R.id.notification_volume_seekbar, R.id.ringer_volume_seekbar,
R.id.alarm_volume_seekbar };
通知铃音和来电铃音是分开的,也就是说这里显示的其实是Ring的铃声大小,并不是通知的铃声大小
./frameworks/base/core/res/res/values/config.xml 内的config_useMasterVolume来决定是否全部是最大声,有客户需求如此,可以客制化此项来尝试。
boolean useMasterVolume = getContext().getResources().
getBoolean(com.android.internal.R.bool.config_useMasterVolume);
if (useMasterVolume) {
// If config_useMasterVolume is true, all streams are treated as STREAM_MASTER.
// So hide all except a stream.
int id;
if (Utils.isVoiceCapable(getContext())) {
id = R.id.ringer_section;
} else {
id = R.id.media_section;
}
for (int i = 0; i < SEEKBAR_SECTION_ID.length; i++) {
if (SEEKBAR_SECTION_ID[i] != id) {
view.findViewById(SEEKBAR_SECTION_ID[i]).setVisibility(View.GONE);
}
}
} else {
// Disable either ringer+notifications or notifications
int id;
if (!Utils.isVoiceCapable(getContext())) {
id = R.id.ringer_section;
} else {
id = R.id.notification_section;
}
View hideSection = view.findViewById(id);
hideSection.setVisibility(View.GONE);
}
在这里对notification_section进行了隐藏设置,那设置铃声的大小,是不是通知铃声其实是不变的?并不是的,通过测试听出,
这里的修改,会同时修改来电铃声和notification的大小。找到设置铃声,二者都会改变的逻辑流程了:
AudioProfileService.java/mRingerVolumeListener/onRingerVolumeChanged/syncRingerVolumeToProfile
此处会同时把来电和通知铃声同时设大
这里主要是区别是支持通话还是不支持通话的项目,分别隐藏铃声&&通知,或者通知的,虽然显示的item是铃声,但是会根据
isVoiceCapable来进行区分设置滴。这个是由./frameworks/base/core/res/res/values/config.xml 内的config_voice_capable决定的
思路清晰了,那么其实对于支持通话的项目,其实WT_CUSTOMER_STREAM_NOTIFICATION_VOLUME这项设置理论应该是无效的,
但是上面说明了在设置中恢复默认设置,会使用到这个,让我们来看看恢复默认设置的逻辑流程吧!
AudioProfileSettings.java/onclick/DIALOG_RESET/ResetTask/mProfileManager.reset()/service.reset()/
AudioProfileService.java/reset();/restoreToDefaultValues/profileState.mRingerVolume = defaultState.mRingerVolume;
defaultState是从AudioProfileManager.java/getDefaultState/final int DEFAULT_RINGER_VOLUME_GENERAL = FeatureOption.WT_CUSTOMER_STREAM_RING_VOLUME;
由此可见恢复默认设置项就还是定义的这个宏
经测试确实存在上述情况,二者不一致会出现默认值不对的情况。分析如下:
由于reset代码中修改了通知的铃声,所以发出了Volume改变信号,监听函数mRingerVolumeListener监听到RingVolume改变了
启动这个函数onRingerVolumeChanged/syncRingerVolumeToProfile,就把里面的两个声音都设置为
(notifyRingerVolumeChanged: oldVolume = 13, newVolume = 7, profile = mtk_audioprofile_general, client = 2)
newVolume了
为什么通知铃声的改动,却可以启动onRingerVolumeChanged回调函数?
AudioService.java/sendVolumeUpdate
if (mStreamVolumeAlias[streamType] == AudioSystem.STREAM_RING) {
notifyRingerVolumeChanged(oldIndex, index, null);
}
if (mVoiceCapable) 别名会根据这个属性归类不同
这里有个别名的定义,若别名里面都归类到Ring了,发生改变都会调用mRingerVolumeListener监听里面的
onRingerVolumeChanged函数,也就会把两个声音都做改变。
其实这里的详细流程是:此时设置的铃声为最大,默认铃声Ringtone=13,NOTIFICATION=7;
点击恢复默认后:
sendVolumeUpdate: StreamType = 2, oldIndex = 15, newIndex = 13
Ringtone先被onRingerVolumeChanged函数改成默认值13,随之而来的是syncRingerVolumeToProfile同步函数设置Notification=13(之前为15)
sendVolumeUpdate: StreamType = 5, oldIndex = 13, newIndex = 7
persistStreamVolumeToSystem: streamType = 5, volume = 7
重置notification为默认值7
调用AudioService.java/sendVolumeUpdate别名判断归类为Ringtone
启动onRingerVolumeChanged函数改成oldIndex = 13, newIndex = 7,随之而来的是syncRingerVolumeToProfile同步函数
设置Notification=7&&Ringtone=7
在config_voice_capable为true的情况下,Notification&&Ringtone二者是捆绑的
所以修改如下:
private static boolean mVoiceCapable;
mVoiceCapable = mContext.getResources().getBoolean(com.android.internal.R.bool.config_voice_capable);
int nwt_usomer_notification_volume = FeatureOption.WT_CUSTOMER_STREAM_NOTIFICATION_VOLUME;
if(mVoiceCapable){
nwt_usomer_notification_volume = FeatureOption.WT_CUSTOMER_STREAM_RING_VOLUME;
}
final int DEFAULT_NOTIFICATION_VOLUME_GENERAL = nwt_usomer_notification_volume;
FeatureOption.WT_CUSTOMER_STREAM_RING_VOLUME 和 FeatureOption.WT_CUSTOMER_STREAM_NOTIFICATION_VOLUME,
这两个在软件 情景模式中是一个吧 叫做Ringtone & notifications。为什么两个宏? 而且注意下,不要把这两个的音量配置成不一样的,要不会有问题。
例如 RING 音量配置的是 7 NOTIFICATION 的音量配置的是3,那么你烧软件或者回复出厂设置的时候,情景模式中这一项音量就是7, 但是在情景模式中有个恢复默认的按钮,点了之后这一项就是3了。会报bug。
看了下在RingerVolumePreference.java文件下
private static final int[] SEEKBAR_ID = new int[] {
R.id.notification_volume_seekbar, R.id.ringer_volume_seekbar,
R.id.alarm_volume_seekbar };
通知铃音和来电铃音是分开的,也就是说这里显示的其实是Ring的铃声大小,并不是通知的铃声大小
./frameworks/base/core/res/res/values/config.xml 内的config_useMasterVolume来决定是否全部是最大声,有客户需求如此,可以客制化此项来尝试。
boolean useMasterVolume = getContext().getResources().
getBoolean(com.android.internal.R.bool.config_useMasterVolume);
if (useMasterVolume) {
// If config_useMasterVolume is true, all streams are treated as STREAM_MASTER.
// So hide all except a stream.
int id;
if (Utils.isVoiceCapable(getContext())) {
id = R.id.ringer_section;
} else {
id = R.id.media_section;
}
for (int i = 0; i < SEEKBAR_SECTION_ID.length; i++) {
if (SEEKBAR_SECTION_ID[i] != id) {
view.findViewById(SEEKBAR_SECTION_ID[i]).setVisibility(View.GONE);
}
}
} else {
// Disable either ringer+notifications or notifications
int id;
if (!Utils.isVoiceCapable(getContext())) {
id = R.id.ringer_section;
} else {
id = R.id.notification_section;
}
View hideSection = view.findViewById(id);
hideSection.setVisibility(View.GONE);
}
在这里对notification_section进行了隐藏设置,那设置铃声的大小,是不是通知铃声其实是不变的?并不是的,通过测试听出,
这里的修改,会同时修改来电铃声和notification的大小。找到设置铃声,二者都会改变的逻辑流程了:
AudioProfileService.java/mRingerVolumeListener/onRingerVolumeChanged/syncRingerVolumeToProfile
此处会同时把来电和通知铃声同时设大
这里主要是区别是支持通话还是不支持通话的项目,分别隐藏铃声&&通知,或者通知的,虽然显示的item是铃声,但是会根据
isVoiceCapable来进行区分设置滴。这个是由./frameworks/base/core/res/res/values/config.xml 内的config_voice_capable决定的
思路清晰了,那么其实对于支持通话的项目,其实WT_CUSTOMER_STREAM_NOTIFICATION_VOLUME这项设置理论应该是无效的,
但是上面说明了在设置中恢复默认设置,会使用到这个,让我们来看看恢复默认设置的逻辑流程吧!
AudioProfileSettings.java/onclick/DIALOG_RESET/ResetTask/mProfileManager.reset()/service.reset()/
AudioProfileService.java/reset();/restoreToDefaultValues/profileState.mRingerVolume = defaultState.mRingerVolume;
defaultState是从AudioProfileManager.java/getDefaultState/final int DEFAULT_RINGER_VOLUME_GENERAL = FeatureOption.WT_CUSTOMER_STREAM_RING_VOLUME;
由此可见恢复默认设置项就还是定义的这个宏
经测试确实存在上述情况,二者不一致会出现默认值不对的情况。分析如下:
由于reset代码中修改了通知的铃声,所以发出了Volume改变信号,监听函数mRingerVolumeListener监听到RingVolume改变了
启动这个函数onRingerVolumeChanged/syncRingerVolumeToProfile,就把里面的两个声音都设置为
(notifyRingerVolumeChanged: oldVolume = 13, newVolume = 7, profile = mtk_audioprofile_general, client = 2)
newVolume了
为什么通知铃声的改动,却可以启动onRingerVolumeChanged回调函数?
AudioService.java/sendVolumeUpdate
if (mStreamVolumeAlias[streamType] == AudioSystem.STREAM_RING) {
notifyRingerVolumeChanged(oldIndex, index, null);
}
if (mVoiceCapable) 别名会根据这个属性归类不同
这里有个别名的定义,若别名里面都归类到Ring了,发生改变都会调用mRingerVolumeListener监听里面的
onRingerVolumeChanged函数,也就会把两个声音都做改变。
其实这里的详细流程是:此时设置的铃声为最大,默认铃声Ringtone=13,NOTIFICATION=7;
点击恢复默认后:
sendVolumeUpdate: StreamType = 2, oldIndex = 15, newIndex = 13
Ringtone先被onRingerVolumeChanged函数改成默认值13,随之而来的是syncRingerVolumeToProfile同步函数设置Notification=13(之前为15)
sendVolumeUpdate: StreamType = 5, oldIndex = 13, newIndex = 7
persistStreamVolumeToSystem: streamType = 5, volume = 7
重置notification为默认值7
调用AudioService.java/sendVolumeUpdate别名判断归类为Ringtone
启动onRingerVolumeChanged函数改成oldIndex = 13, newIndex = 7,随之而来的是syncRingerVolumeToProfile同步函数
设置Notification=7&&Ringtone=7
在config_voice_capable为true的情况下,Notification&&Ringtone二者是捆绑的
所以修改如下:
private static boolean mVoiceCapable;
mVoiceCapable = mContext.getResources().getBoolean(com.android.internal.R.bool.config_voice_capable);
int nwt_usomer_notification_volume = FeatureOption.WT_CUSTOMER_STREAM_NOTIFICATION_VOLUME;
if(mVoiceCapable){
nwt_usomer_notification_volume = FeatureOption.WT_CUSTOMER_STREAM_RING_VOLUME;
}
final int DEFAULT_NOTIFICATION_VOLUME_GENERAL = nwt_usomer_notification_volume;