Android SystemUI 音量条VolumeDialogImpl更新

本文深入探讨Android系统UI中的VolumeDialogImpl更新,涉及AudioService的adjustStreamVolume方法,重点讲解如何显示UI及其条件。内容涵盖VolumeController、VolumeDialogControllerImpl的工作原理,包括业务处理、音量条开关、主动流更新以及回调函数的作用,尤其是VolumeDialogImpl在音量条显示和关闭中的关键角色。同时,提到了用户活动如何影响系统休眠时间的设定。
摘要由CSDN通过智能技术生成

1.AudioService::adjustStreamVolume

    private void adjustStreamVolume(int streamType, int direction, int flags,
            String callingPackage, String caller, int uid) {
......
//finally update notify systemui to update
        int index = mStreamStates[streamType].getIndex(device);
        sendVolumeUpdate(streamType, oldIndex, index, flags);

2.flags一定要是奇数才能显示UI,对应Audiomanager 中public static final int FLAG_SHOW_UI = 1 << 0;

    // UI update and Broadcast Intent
    protected void sendVolumeUpdate(int streamType, int oldIndex, int index, int flags) {
        streamType = mStreamVolumeAlias[streamType];

        if (streamType == AudioSystem.STREAM_MUSIC) {
            flags = updateFlagsForSystemAudio(flags);
        }
        mVolumeController.postVolumeChanged(streamType, flags);
    }

3.mVolumeController是AudioService的内部类VolumeController,封装了VolumeDialogControllerImpl,也就是mController,这是SystemUI启动的时候通过AudioManager的setVolumeController设置的。

        public void postVolumeChanged(int streamType, int flags) {
            if (mController == null)
                return;
            try {
                mController.volumeChanged(streamType, flags);
            } catch (RemoteException e) {
                Log.w(TAG, "Error calling volumeChanged", e);
            }
        }

4.SystemUI VolumeDialogControllerImpl内部类的VC

    private final class VC extends IVolumeController.Stub {
...
        @Override
        public void volumeChanged(int streamType, int flags) throws RemoteException {
            if (D.BUG) Log.d(TAG, "volumeChanged " + AudioSystem.streamToString(streamType)
                    + " " + Util.audioManagerFlagsToString(flags));
    
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值