Android Audio Practical Combat - Silent Settings (Seventeen)

        Volume adjustment is a very important function for car audio development, which is mainly divided into system volume, call volume, navigation volume, ringtone volume, voice volume (third-party applications such as WeChat), etc. The volume adjustment has been analyzed in detail before, but it is still necessary to analyze the volume mute function here.

1. Functional packaging

        For the encapsulation of volume adjustment, we often place it under the Setting module, so here we also place the interface in SysSettingAdapter. We also saw the corresponding encapsulation in the previous volume setting.

1、SysSettingAdapter

        SysSettingAdapter all belong to merchant customized function modules, so they are generally located under the /vendor/ module.

private final AudioManager mAudioManager;
private CarAudioManager mCarAudioManager;

public SysSettingsAdapter(Context context) {  
     mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
}

public void infoAudioMedia(){
    // 初始化媒体音,即设置默认值
}

/**
 * 获取媒体音是否可以静音
 */
public void getAudioMediaMuteEnable(){
    // 通过本地Settings.System.getInt获取相关数据即可
}

/**
 * 设置媒体音是否可以静音
 */
public void setAudioMediaMuteEnable(boolean state){
    // 通过本地Settings.System.putInt保存相关数据即可
}

/**
 * 获取媒体音是否静音
 */
public void getAudioMediaMute

Guess you like

Origin blog.csdn.net/c19344881x/article/details/134325943