Android AudioManager修改设备默认音量

Android 4.4:

修改AudioManager中的默认音量数组:

frameworks/base/media/java/android/media/AudioManager.java

    public static final int[] DEFAULT_STREAM_VOLUME = new int[] {
        4, // STREAM_VOICE_CALL
        7, // STREAM_SYSTEM
        4, // STREAM_RING
        8, // STREAM_MUSIC
        4, // STREAM_ALARM
        4, // STREAM_NOTIFICATION
        7, // STREAM_BLUETOOTH_SCO
        7, // STREAM_SYSTEM_ENFORCED
        11, // STREAM_DTMF
        11, // STREAM_TTS
        4, // STREAM_FM
        4 // STREAM_MATV
    };


Android 5.1:

AudioManager中没有4.4中的DEFAULT_STREAM_VOLUME 数组,移动到了AudioService:

frameworks/base/media/java/android/media/AudioService.java

    /**
     * @hide Default volume index values for audio streams
     * M: modify the default stream volume @{
     */
    public static int[] DEFAULT_STREAM_VOLUME = new int[] {
        4,  // STREAM_VOICE_CALL
        15,  // STREAM_SYSTEM
        8,  // STREAM_RING
        8, // STREAM_MUSIC
        8,  // STREAM_ALARM
        8,  // STREAM_NOTIFICATION
        7,  // STREAM_BLUETOOTH_SCO
        15,  // STREAM_SYSTEM_ENFORCED
        11, // STREAM_DTMF
        11,  // STREAM_TTS
    };
    /** @ */


附:最大音量

   /** @hide Maximum volume index values for audio streams */
   /// M: Modify the max stream volume @{
    private static final int[] MAX_STREAM_VOLUME = new int[] {
        6,  // STREAM_VOICE_CALL
        15,  // STREAM_SYSTEM
        15,  // STREAM_RING
        15, // STREAM_MUSIC
        15,  // STREAM_ALARM
        15,  // STREAM_NOTIFICATION
        15, // STREAM_BLUETOOTH_SCO
        15,  // STREAM_SYSTEM_ENFORCED
        15, // STREAM_DTMF
        15,  // STREAM_TTS
    };
    /// @}


你可能感兴趣的:(Android)