微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > mt6735 收音机音量开到最大都没有“将音量调高到安全级别以上?会损坏...

mt6735 收音机音量开到最大都没有“将音量调高到安全级别以上?会损坏...

时间:10-02 整理:3721RD 点击:
[Audio APP]收音机音量开到最大都没有“将音量调高到安全级别以上?会损坏听力”提示
[DESCRIPTION]
插入耳机端口,打开音乐。侧键音量开到最大,出现提示框“将音量调高到安全级别以上?会损坏听力”这样的提示。
而同样的路径打开收音机,点击侧音量键把音量调到最大,没有相应的提示。
[SOLUTION]
修改
1,privatestaticfinalintMSG_CHECK_FM_ACTIVE=29;

2,privatevoidonCheckFmActive(){
synchronized(mSafeMediaVolumeState){
if(mSafeMediaVolumeState==SAFE_MEDIA_VOLUME_INACTIVE){
intdevice=getDeviceForStream(AudioSystem.STREAM_FM);
if((device&mSafeMediaVolumeDevices)!=0){
sendMsg(mAudioHandler,MSG_CHECK_FM_ACTIVE,SENDMSG_REPLACE,0,0,null,
FM_ACTIVE_POLL_PERIOD_MS);
intindex=mStreamStates[AudioSystem.STREAM_FM]
.getIndex(device,false/*lastAudible*/);
if(AudioSystem.isStreamActive(AudioSystem.STREAM_FM,0)
&&(index>mSafeMediaVolumeIndex)){
//Approximatecumulativeactivemusictime
mFmEMS+=FM_ACTIVE_POLL_PERIOD_MS;
if(mFmeMs>UNSAFE_VOLUME_FM_ACTIVE_MS_MAX){
setSafeMediaVolumeEnabled(true);
mFmeMs=0;
mVolumePanel.postDisplaySafeVolumeWarning();
}
}
}
}
}
}

3,在caseMSG_CHECK_MUSIC_ACTIVE:
onCheckMusicActive();
break;
后面增加
///M:safemediaforFM@{
caseMSG_CHECK_FM_ACTIVE:
onCheckFmActive();
break;
///safemediaforFM@}

4,在privatevoidonSetWiredDeviceConnectionState(intdevice,intstate,Stringname)
sendMsg(mAudioHandler,
MSG_CHECK_MUSIC_ACTIVE,
SENDMSG_REPLACE,
0,
0,
null,
MUSIC_ACTIVE_POLL_PERIOD_MS);
后面增加
///safemediaforFM@{
sendMsg(mAudioHandler,MSG_CHECK_FM_ACTIVE,SENDMSG_REPLACE,0,0,null,
FM_ACTIVE_POLL_PERIOD_MS);
///safemediaforFM@}

5,在privatestaticfinalintSAFE_VOLUME_CONFIGURE_TIMEOUT_MS=30000;//30safterbootcompleted后面增加如下
privateintmFmeMs;
privatestaticfinalintUNSAFE_VOLUME_FM_ACTIVE_MS_MAX=(20*3600*1000);//20
//hours
privatestaticfinalintFM_ACTIVE_POLL_PERIOD_MS=60000;//1minute

6,以下几个函数改为如下
privatevoidsetSafeMediaVolumeEnabled(booleanon){
synchronized(mSafeMediaVolumeState){
if((mSafeMediaVolumeState!=SAFE_MEDIA_VOLUME_NOT_CONFIGURED)
&&(mSafeMediaVolumeState!=SAFE_MEDIA_VOLUME_DISABLED)){
if(on&&(mSafeMediaVolumeState==SAFE_MEDIA_VOLUME_INACTIVE)){
mSafeMediaVolumeState=SAFE_MEDIA_VOLUME_ACTIVE;
enforceSafeMediaVolume();
}elseif(!on&&(mSafeMediaVolumeState==SAFE_MEDIA_VOLUME_ACTIVE)){
mSafeMediaVolumeState=SAFE_MEDIA_VOLUME_INACTIVE;
mMusicActiveMs=0;
sendMsg(mAudioHandler,MSG_CHECK_MUSIC_ACTIVE,SENDMSG_REPLACE,0,0,null,
MUSIC_ACTIVE_POLL_PERIOD_MS);
mFmeMs=0;
sendMsg(mAudioHandler,MSG_CHECK_FM_ACTIVE,SENDMSG_REPLACE,0,0,null,
FM_ACTIVE_POLL_PERIOD_MS);
}
}
}
}
privatevoidenforceSafeMediaVolume(){
enforceSafeMediaVolume(AudioSystem.STREAM_MUSIC);
enforceSafeMediaVolume(AudioSystem.STREAM_FM);
}
privatevoidenforceSafeMediaVolume(intstreamType){
VolumeStreamStatestreamState=mStreamStates[streamType];
booleanlastAudible=(streamState.muteCount()!=0);
intdevices=mSafeMediaVolumeDevices;
inti=0;
while(devices!=0){
intdevice=1<<i++;
if((device&devices)==0){
continue;
}
intindex=streamState.getIndex(device,lastAudible);
if(index>mSafeMediaVolumeIndex){
if(lastAudible){
streamState.setLastAudibleIndex(mSafeMediaVolumeIndex,device);
sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,SENDMSG_QUEUE,PERSIST_LAST_AUDIBLE,
device,streamState,PERSIST_DELAY);
}else{
streamState.setIndex(mSafeMediaVolumeIndex,device,true);
sendMsg(mAudioHandler,MSG_SET_DEVICE_VOLUME,SENDMSG_QUEUE,device,0,
streamState,0);
}
}
devices&=~device;
}
}
privatebooleancheckSafeMediaVolume(intstreamType,intindex,intdevice){
synchronized(mSafeMediaVolumeState){
if((mSafeMediaVolumeState==SAFE_MEDIA_VOLUME_ACTIVE)
&&(mStreamVolumeAlias[streamType]==AudioSystem.STREAM_MUSIC||mStreamVolumeAlias[streamType]==AudioSystem
.STREAM_FM)
&&((device&mSafeMediaVolumeDevices)!=0)&&(index>mSafeMediaVolumeIndex)){
mVolumePanel.postDisplaySafeVolumeWarning();
returnfalse;
}
returntrue;
}
}
///safemediaforFM@}
(alps/php?mod=tag&id=6090" target="_blank" class="relatedlink">Frameworks/base/media/java/android/media/AudioService.java)
然后
mkxxx(project_name)mmframeworks/base
adbremount
adbpushframework.jarsystem/framework
adbreboot
即可验证功能。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top