RK3288[android 7.1]调试笔记 修改默认Music, video, games, & other media音乐,视频,游戏,铃声和通知等音量设置为70%
修改路径为/frameworks/base/media/java/android/media/AudioSystem.java文件
wangxd@build-server-100:~/work/dsy/rk3288-Android-7.0/frameworks/base(m_android_7_0)$ git diff media/java/android/media/AudioSystem.java
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
old mode 100644
new mode 100755
index f597440…219089c
— a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -762,16 +762,16 @@ public class AudioSystem
}
public static int[] DEFAULT_STREAM_VOLUME = new int[] {//这里修改默认的音量值 11/15=0.73 接近70%
-
4, // STREAM_VOICE_CALL
-
7, // STREAM_SYSTEM
-
5, // STREAM_RING
-
11, // STREAM_VOICE_CALL
-
11, // STREAM_SYSTEM
-
11, // STREAM_RING 11, // STREAM_MUSIC
-
6, // STREAM_ALARM
-
5, // STREAM_NOTIFICATION
-
7, // STREAM_BLUETOOTH_SCO
-
7, // STREAM_SYSTEM_ENFORCED
-
11, // STREAM_DTMF
-
11 // STREAM_TTS
-
11, // STREAM_ALARM
-
11, // STREAM_NOTIFICATION
-
11, // STREAM_BLUETOOTH_SCO
-
11, // STREAM_SYSTEM_ENFORCED
-
11, // STREAM_DTMF
-
11 // STREAM_TTS
};
public static String streamToString(int stream) {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
修改路径为/frameworks/base/services/core/java/com/android/server/audio/AudioService.java文件
wangxd@build-server-100:~/work/dsy/rk3288-Android-7.0/frameworks/base(m_android_7_0)$ git diff services/core/java/com/android/server/audio/AudioService.java
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/serve
old mode 100644
new mode 100755
index 40ae864…3fd67a3
— a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -261,14 +261,14 @@ public class AudioService extends IAudioService.Stub {
/** Maximum volume index values for audio streams */
private static int[] MAX_STREAM_VOLUME = new int[] {//这里修改音量的最大值都设为15
-
5, // STREAM_VOICE_CALL
-
7, // STREAM_SYSTEM
-
7, // STREAM_RING
-
15, // STREAM_VOICE_CALL
-
15, // STREAM_SYSTEM
-
15, // STREAM_RING 15, // STREAM_MUSIC
-
7, // STREAM_ALARM
-
7, // STREAM_NOTIFICATION
-
15, // STREAM_ALARM
-
15, // STREAM_NOTIFICATION 15, // STREAM_BLUETOOTH_SCO
-
7, // STREAM_SYSTEM_ENFORCED
-
};15, // STREAM_SYSTEM_ENFORCED 15, // STREAM_DTMF 15 // STREAM_TTS
/** Minimum volume index values for audio streams */
private static int[] MIN_STREAM_VOLUME = new int[] {//这里使用是默认的音量最小值
1, // STREAM_VOICE_CALL
0, // STREAM_SYSTEM
0, // STREAM_RING
0, // STREAM_MUSIC
0, // STREAM_ALARM
0, // STREAM_NOTIFICATION
0, // STREAM_BLUETOOTH_SCO
0, // STREAM_SYSTEM_ENFORCED
0, // STREAM_DTMF
0 // STREAM_TTS
};
@@ -614,19 +614,19 @@ public class AudioService extends IAudioService.Stub {
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
mHasVibrator = vibrator == null ? false : vibrator.hasVibrator();
-
// Initialize volume
-
int maxVolume = SystemProperties.getInt("ro.config.vc_call_vol_steps",
-
MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]);
-
if (maxVolume != MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]) {
-
MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = maxVolume;
-
AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = (maxVolume * 3) / 4;
-
}
-
maxVolume = SystemProperties.getInt("ro.config.media_vol_steps",
-
MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC]);
-
if (maxVolume != MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC]) {
-
MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = maxVolume;
-
AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = (maxVolume * 3) / 4;
-
} //这里把在system.prop获取的音量设定值给屏蔽掉使用上面修改的值,为什么要屏蔽掉,原因是如果在system.prop获取的音量设定值与我们修改在上面默认音量值,默认音量最大值,默认音量最小值的结构体里的值不一致,会把我们的设定值变为设定值的3/4
-
// // Initialize volume
-
// int maxVolume = SystemProperties.getInt("ro.config.vc_call_vol_steps",
-
// MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]);
-
// if (maxVolume != MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]) {
-
// MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = maxVolume;
-
// AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = (maxVolume * 3) / 4;
-
// }
-
// maxVolume = SystemProperties.getInt("ro.config.media_vol_steps",
-
// MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC]);
-
// if (maxVolume != MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC]) {
-
// MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = maxVolume;
-
// AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = (maxVolume * 3) / 4;
-
// } sSoundEffectVolumeDb = context.getResources().getInteger( com.android.internal.R.integer.config_soundEffectVolumeDb);
————————————————
版权声明:本文为CSDN博主「d海阔天空」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/MrDongShiYi/article/details/93973764