按文件分步骤,代码版本Android6.0.1
1.上层调用AudioManager的接口,要么是setStreamVolume(),要么是按了音量键adjustStreamVolume().
2.AudioService.java:
1.1分两种情况
情况一:如果setStreamVolume()--------------------------应用层调用
(1)setStreamVolume()
onSetStreamVolume(streamType, index, flags, device, caller);
(2) onSetStreamVolume()
setStreamVolumeInt(stream, index, device, false, caller);
(3)setStreamVolumeInt()
sendMsg(mAudioHandler,
MSG_SET_DEVICE_VOLUME,
SENDMSG_QUEUE,
device,
0,
streamState,
0);
mAudioHandler定义:AudioHandler mAudioHandler;
->case MSG_SET_DEVICE_VOLUME:
setDeviceVolume((VolumeStreamState) msg.obj, msg.arg1);
break;
情况二:如果adjustStreamVolume()-----------------------------音量键
直接
send
Andorid6.0音量调整(设置)流程
最新推荐文章于 2024-07-08 11:15:26 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)