Android 8.1 铃声音量通话音量同步调节

Android 8.1 铃声音量通话音量同步调节

最近收到客户反馈,想要实现铃声音量通话音量同步调节,具体修改参照如下:

/frameworks/base/core/java/android/preference/SeekBarVolumizer.java

        if (defaultUri == null) {
            if (mStreamType == AudioManager.STREAM_RING) {
                defaultUri = Settings.System.DEFAULT_RINGTONE_URI;
            } else if (mStreamType == AudioManager.STREAM_NOTIFICATION) {
                defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
            //*/tyd.zcb, 20240116. voice call set null
            } else if (mStreamType == AudioManager.STREAM_ALARM) {
                defaultUri = Settings.System.DEFAULT_ALARM_ALERT_URI;
            } else {
                defaultUri = null;
            }
            /*/
            } else {
                defaultUri = Settings.System.DEFAULT_ALARM_ALERT_URI;
            }
            //*/

/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/notification/SoundSettings.java

        public void onStreamValueChanged(int stream, int progress) {
+            if (stream == AudioManager.STREAM_VOICE_CALL) {
+                AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+                audioManager.setStreamVolume(stream, progress, 0);
+            }
        }

重新编译验证,修改生效,铃声音量通话音量已实现同步调节

你可能感兴趣的:(Android,framework,android)