am 670a82cb: Merge "audioservice: fix default stream volume" into lmp-mr1-dev

* commit '670a82cbb1b62e69fa7ef7387eed545a76c96f76':
  audioservice: fix default stream volume
This commit is contained in:
Eric Laurent
2014-10-27 20:36:54 +00:00
committed by Android Git Automerger
3 changed files with 41 additions and 32 deletions

View File

@@ -353,21 +353,6 @@ public class AudioManager {
*/ */
@Deprecated public static final int NUM_STREAMS = AudioSystem.NUM_STREAMS; @Deprecated public static final int NUM_STREAMS = AudioSystem.NUM_STREAMS;
/** @hide Default volume index values for audio streams */
public static final int[] DEFAULT_STREAM_VOLUME = new int[] {
4, // STREAM_VOICE_CALL
7, // STREAM_SYSTEM
5, // 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
};
/** /**
* Increase the ringer volume. * Increase the ringer volume.
* *

View File

@@ -248,7 +248,7 @@ public class AudioService extends IAudioService.Stub {
private final int[][] SOUND_EFFECT_FILES_MAP = new int[AudioManager.NUM_SOUND_EFFECTS][2]; private final int[][] SOUND_EFFECT_FILES_MAP = new int[AudioManager.NUM_SOUND_EFFECTS][2];
/** @hide Maximum volume index values for audio streams */ /** @hide Maximum volume index values for audio streams */
private static final int[] MAX_STREAM_VOLUME = new int[] { private static int[] MAX_STREAM_VOLUME = new int[] {
5, // STREAM_VOICE_CALL 5, // STREAM_VOICE_CALL
7, // STREAM_SYSTEM 7, // STREAM_SYSTEM
7, // STREAM_RING 7, // STREAM_RING
@@ -260,6 +260,20 @@ public class AudioService extends IAudioService.Stub {
15, // STREAM_DTMF 15, // STREAM_DTMF
15 // STREAM_TTS 15 // STREAM_TTS
}; };
private static int[] DEFAULT_STREAM_VOLUME = new int[] {
4, // STREAM_VOICE_CALL
7, // STREAM_SYSTEM
5, // 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
};
/* mStreamVolumeAlias[] indicates for each stream if it uses the volume settings /* mStreamVolumeAlias[] indicates for each stream if it uses the volume settings
* of another stream: This avoids multiplying the volume settings for hidden * of another stream: This avoids multiplying the volume settings for hidden
* stream types that follow other stream behavior for volume settings * stream types that follow other stream behavior for volume settings
@@ -541,12 +555,18 @@ public class AudioService extends IAudioService.Stub {
mHasVibrator = vibrator == null ? false : vibrator.hasVibrator(); mHasVibrator = vibrator == null ? false : vibrator.hasVibrator();
// Intialized volume // Intialized volume
MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = SystemProperties.getInt( int maxVolume = SystemProperties.getInt("ro.config.vc_call_vol_steps",
"ro.config.vc_call_vol_steps", MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]);
MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]); if (maxVolume != MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]) {
MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = SystemProperties.getInt( MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = maxVolume;
"ro.config.media_vol_steps", DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = (maxVolume * 3) / 4;
MAX_STREAM_VOLUME[AudioSystem.STREAM_MUSIC]); }
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;
DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = (maxVolume * 3) / 4;
}
sSoundEffectVolumeDb = context.getResources().getInteger( sSoundEffectVolumeDb = context.getResources().getInteger(
com.android.internal.R.integer.config_soundEffectVolumeDb); com.android.internal.R.integer.config_soundEffectVolumeDb);
@@ -1625,6 +1645,10 @@ public class AudioService extends IAudioService.Stub {
return MAX_STREAM_VOLUME[streamType]; return MAX_STREAM_VOLUME[streamType];
} }
public static int getDefaultStreamVolume(int streamType) {
return DEFAULT_STREAM_VOLUME[streamType];
}
/** @see AudioManager#getStreamVolume(int) */ /** @see AudioManager#getStreamVolume(int) */
public int getStreamVolume(int streamType) { public int getStreamVolume(int streamType) {
ensureValidStreamType(streamType); ensureValidStreamType(streamType);
@@ -3356,7 +3380,7 @@ public class AudioService extends IAudioService.Stub {
// only be stale values // only be stale values
if ((mStreamType == AudioSystem.STREAM_SYSTEM) || if ((mStreamType == AudioSystem.STREAM_SYSTEM) ||
(mStreamType == AudioSystem.STREAM_SYSTEM_ENFORCED)) { (mStreamType == AudioSystem.STREAM_SYSTEM_ENFORCED)) {
int index = 10 * AudioManager.DEFAULT_STREAM_VOLUME[mStreamType]; int index = 10 * DEFAULT_STREAM_VOLUME[mStreamType];
synchronized (mCameraSoundForced) { synchronized (mCameraSoundForced) {
if (mCameraSoundForced) { if (mCameraSoundForced) {
index = mIndexMax; index = mIndexMax;
@@ -3380,7 +3404,7 @@ public class AudioService extends IAudioService.Stub {
// if no volume stored for current stream and device, use default volume if default // if no volume stored for current stream and device, use default volume if default
// device, continue otherwise // device, continue otherwise
int defaultIndex = (device == AudioSystem.DEVICE_OUT_DEFAULT) ? int defaultIndex = (device == AudioSystem.DEVICE_OUT_DEFAULT) ?
AudioManager.DEFAULT_STREAM_VOLUME[mStreamType] : -1; DEFAULT_STREAM_VOLUME[mStreamType] : -1;
int index = Settings.System.getIntForUser( int index = Settings.System.getIntForUser(
mContentResolver, name, defaultIndex, UserHandle.USER_CURRENT); mContentResolver, name, defaultIndex, UserHandle.USER_CURRENT);
if (index == -1) { if (index == -1) {

View File

@@ -568,7 +568,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
+ " VALUES(?,?);"); + " VALUES(?,?);");
loadSetting(stmt, Settings.System.VOLUME_BLUETOOTH_SCO, loadSetting(stmt, Settings.System.VOLUME_BLUETOOTH_SCO,
AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_BLUETOOTH_SCO]); AudioService.getDefaultStreamVolume(AudioManager.STREAM_BLUETOOTH_SCO));
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
db.endTransaction(); db.endTransaction();
@@ -2169,25 +2169,25 @@ public class DatabaseHelper extends SQLiteOpenHelper {
+ " VALUES(?,?);"); + " VALUES(?,?);");
loadSetting(stmt, Settings.System.VOLUME_MUSIC, loadSetting(stmt, Settings.System.VOLUME_MUSIC,
AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_MUSIC]); AudioService.getDefaultStreamVolume(AudioManager.STREAM_MUSIC));
loadSetting(stmt, Settings.System.VOLUME_RING, loadSetting(stmt, Settings.System.VOLUME_RING,
AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_RING]); AudioService.getDefaultStreamVolume(AudioManager.STREAM_RING));
loadSetting(stmt, Settings.System.VOLUME_SYSTEM, loadSetting(stmt, Settings.System.VOLUME_SYSTEM,
AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_SYSTEM]); AudioService.getDefaultStreamVolume(AudioManager.STREAM_SYSTEM));
loadSetting( loadSetting(
stmt, stmt,
Settings.System.VOLUME_VOICE, Settings.System.VOLUME_VOICE,
AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_VOICE_CALL]); AudioService.getDefaultStreamVolume(AudioManager.STREAM_VOICE_CALL));
loadSetting(stmt, Settings.System.VOLUME_ALARM, loadSetting(stmt, Settings.System.VOLUME_ALARM,
AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_ALARM]); AudioService.getDefaultStreamVolume(AudioManager.STREAM_ALARM));
loadSetting( loadSetting(
stmt, stmt,
Settings.System.VOLUME_NOTIFICATION, Settings.System.VOLUME_NOTIFICATION,
AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_NOTIFICATION]); AudioService.getDefaultStreamVolume(AudioManager.STREAM_NOTIFICATION));
loadSetting( loadSetting(
stmt, stmt,
Settings.System.VOLUME_BLUETOOTH_SCO, Settings.System.VOLUME_BLUETOOTH_SCO,
AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_BLUETOOTH_SCO]); AudioService.getDefaultStreamVolume(AudioManager.STREAM_BLUETOOTH_SCO));
// By default: // By default:
// - ringtones, notification, system and music streams are affected by ringer mode // - ringtones, notification, system and music streams are affected by ringer mode