Loading media/java/android/media/AudioService.java +16 −9 Original line number Diff line number Diff line Loading @@ -332,10 +332,10 @@ public class AudioService extends IAudioService.Stub { SOUND_EFFECT_DEFAULT_VOLUME_DB); mVolumePanel = new VolumePanel(context, this); mSettingsObserver = new SettingsObserver(); mForcedUseForComm = AudioSystem.FORCE_NONE; createAudioSystemThread(); readPersistedSettings(); mSettingsObserver = new SettingsObserver(); createStreamStates(); // Call setMode() to initialize mSetModeDeathHandlers mMode = AudioSystem.MODE_INVALID; Loading Loading @@ -433,15 +433,20 @@ public class AudioService extends IAudioService.Stub { mVibrateSetting = System.getInt(cr, System.VIBRATE_ON, 0); // make sure settings for ringer mode are consistent with device type: non voice capable // devices (tablets) include media stream in silent mode whereas phones don't. mRingerModeAffectedStreams = Settings.System.getInt(cr, Settings.System.MODE_RINGER_STREAMS_AFFECTED, ((1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_NOTIFICATION)| (1 << AudioSystem.STREAM_SYSTEM)|(1 << AudioSystem.STREAM_SYSTEM_ENFORCED)| (1 << AudioSystem.STREAM_MUSIC))); if (!mVoiceCapable) { (1 << AudioSystem.STREAM_SYSTEM)|(1 << AudioSystem.STREAM_SYSTEM_ENFORCED))); if (mVoiceCapable) { mRingerModeAffectedStreams &= ~(1 << AudioSystem.STREAM_MUSIC); } else { mRingerModeAffectedStreams |= (1 << AudioSystem.STREAM_MUSIC); } Settings.System.putInt(cr, Settings.System.MODE_RINGER_STREAMS_AFFECTED, mRingerModeAffectedStreams); mMuteAffectedStreams = System.getInt(cr, System.MUTE_STREAMS_AFFECTED, ((1 << AudioSystem.STREAM_MUSIC)|(1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_SYSTEM))); Loading Loading @@ -2173,11 +2178,13 @@ public class AudioService extends IAudioService.Stub { synchronized (mSettingsLock) { int ringerModeAffectedStreams = Settings.System.getInt(mContentResolver, Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); if (!mVoiceCapable) { ((1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_NOTIFICATION)| (1 << AudioSystem.STREAM_SYSTEM)|(1 << AudioSystem.STREAM_SYSTEM_ENFORCED))); if (mVoiceCapable) { ringerModeAffectedStreams &= ~(1 << AudioSystem.STREAM_MUSIC); } else { ringerModeAffectedStreams |= (1 << AudioSystem.STREAM_MUSIC); } if (ringerModeAffectedStreams != mRingerModeAffectedStreams) { /* * Ensure all stream types that should be affected by ringer mode Loading packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +53 −8 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ public class DatabaseHelper extends SQLiteOpenHelper { // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion' // is properly propagated through your change. Not doing so will result in a loss of user // settings. private static final int DATABASE_VERSION = 66; private static final int DATABASE_VERSION = 67; private Context mContext; Loading Loading @@ -861,6 +861,36 @@ public class DatabaseHelper extends SQLiteOpenHelper { upgradeVersion = 66; } if (upgradeVersion == 66) { // This upgrade makes sure that MODE_RINGER_STREAMS_AFFECTED and // NOTIFICATIONS_USE_RING_VOLUME settings are set according to device voice capability db.beginTransaction(); try { int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) | (1 << AudioManager.STREAM_NOTIFICATION) | (1 << AudioManager.STREAM_SYSTEM) | (1 << AudioManager.STREAM_SYSTEM_ENFORCED); if (!mContext.getResources().getBoolean( com.android.internal.R.bool.config_voice_capable)) { ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC); db.execSQL("DELETE FROM system WHERE name='" + Settings.System.NOTIFICATIONS_USE_RING_VOLUME + "'"); db.execSQL("INSERT INTO system ('name', 'value') values ('" + Settings.System.NOTIFICATIONS_USE_RING_VOLUME + "', '1')"); } db.execSQL("DELETE FROM system WHERE name='" + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'"); db.execSQL("INSERT INTO system ('name', 'value') values ('" + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '" + String.valueOf(ringerModeAffectedStreams) + "')"); db.setTransactionSuccessful(); } finally { db.endTransaction(); } upgradeVersion = 67; } // *** Remember to update DATABASE_VERSION above! if (upgradeVersion != currentVersion) { Loading Loading @@ -1121,11 +1151,21 @@ public class DatabaseHelper extends SQLiteOpenHelper { loadVibrateSetting(db, false); // By default, only the ring/notification, system and music streams are affected // By default: // - ringtones, notification, system and music streams are affected by ringer mode // on non voice capable devices (tablets) // - ringtones, notification and system streams are affected by ringer mode // on voice capable devices (phones) int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) | (1 << AudioManager.STREAM_NOTIFICATION) | (1 << AudioManager.STREAM_SYSTEM) | (1 << AudioManager.STREAM_SYSTEM_ENFORCED); if (!mContext.getResources().getBoolean( com.android.internal.R.bool.config_voice_capable)) { ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC); } loadSetting(stmt, Settings.System.MODE_RINGER_STREAMS_AFFECTED, (1 << AudioManager.STREAM_RING) | (1 << AudioManager.STREAM_NOTIFICATION) | (1 << AudioManager.STREAM_SYSTEM) | (1 << AudioManager.STREAM_SYSTEM_ENFORCED) | (1 << AudioManager.STREAM_MUSIC)); ringerModeAffectedStreams); loadSetting(stmt, Settings.System.MUTE_STREAMS_AFFECTED, ((1 << AudioManager.STREAM_MUSIC) | Loading Loading @@ -1232,8 +1272,13 @@ public class DatabaseHelper extends SQLiteOpenHelper { R.bool.def_vibrate_in_silent); // Set notification volume to follow ringer volume by default if (mContext.getResources().getBoolean( com.android.internal.R.bool.config_voice_capable)) { loadBooleanSetting(stmt, Settings.System.NOTIFICATIONS_USE_RING_VOLUME, R.bool.def_notifications_use_ring_volume); } else { loadSetting(stmt, Settings.System.NOTIFICATIONS_USE_RING_VOLUME, "1"); } loadIntegerSetting(stmt, Settings.System.POINTER_SPEED, R.integer.def_pointer_speed); Loading Loading
media/java/android/media/AudioService.java +16 −9 Original line number Diff line number Diff line Loading @@ -332,10 +332,10 @@ public class AudioService extends IAudioService.Stub { SOUND_EFFECT_DEFAULT_VOLUME_DB); mVolumePanel = new VolumePanel(context, this); mSettingsObserver = new SettingsObserver(); mForcedUseForComm = AudioSystem.FORCE_NONE; createAudioSystemThread(); readPersistedSettings(); mSettingsObserver = new SettingsObserver(); createStreamStates(); // Call setMode() to initialize mSetModeDeathHandlers mMode = AudioSystem.MODE_INVALID; Loading Loading @@ -433,15 +433,20 @@ public class AudioService extends IAudioService.Stub { mVibrateSetting = System.getInt(cr, System.VIBRATE_ON, 0); // make sure settings for ringer mode are consistent with device type: non voice capable // devices (tablets) include media stream in silent mode whereas phones don't. mRingerModeAffectedStreams = Settings.System.getInt(cr, Settings.System.MODE_RINGER_STREAMS_AFFECTED, ((1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_NOTIFICATION)| (1 << AudioSystem.STREAM_SYSTEM)|(1 << AudioSystem.STREAM_SYSTEM_ENFORCED)| (1 << AudioSystem.STREAM_MUSIC))); if (!mVoiceCapable) { (1 << AudioSystem.STREAM_SYSTEM)|(1 << AudioSystem.STREAM_SYSTEM_ENFORCED))); if (mVoiceCapable) { mRingerModeAffectedStreams &= ~(1 << AudioSystem.STREAM_MUSIC); } else { mRingerModeAffectedStreams |= (1 << AudioSystem.STREAM_MUSIC); } Settings.System.putInt(cr, Settings.System.MODE_RINGER_STREAMS_AFFECTED, mRingerModeAffectedStreams); mMuteAffectedStreams = System.getInt(cr, System.MUTE_STREAMS_AFFECTED, ((1 << AudioSystem.STREAM_MUSIC)|(1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_SYSTEM))); Loading Loading @@ -2173,11 +2178,13 @@ public class AudioService extends IAudioService.Stub { synchronized (mSettingsLock) { int ringerModeAffectedStreams = Settings.System.getInt(mContentResolver, Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); if (!mVoiceCapable) { ((1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_NOTIFICATION)| (1 << AudioSystem.STREAM_SYSTEM)|(1 << AudioSystem.STREAM_SYSTEM_ENFORCED))); if (mVoiceCapable) { ringerModeAffectedStreams &= ~(1 << AudioSystem.STREAM_MUSIC); } else { ringerModeAffectedStreams |= (1 << AudioSystem.STREAM_MUSIC); } if (ringerModeAffectedStreams != mRingerModeAffectedStreams) { /* * Ensure all stream types that should be affected by ringer mode Loading
packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +53 −8 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ public class DatabaseHelper extends SQLiteOpenHelper { // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion' // is properly propagated through your change. Not doing so will result in a loss of user // settings. private static final int DATABASE_VERSION = 66; private static final int DATABASE_VERSION = 67; private Context mContext; Loading Loading @@ -861,6 +861,36 @@ public class DatabaseHelper extends SQLiteOpenHelper { upgradeVersion = 66; } if (upgradeVersion == 66) { // This upgrade makes sure that MODE_RINGER_STREAMS_AFFECTED and // NOTIFICATIONS_USE_RING_VOLUME settings are set according to device voice capability db.beginTransaction(); try { int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) | (1 << AudioManager.STREAM_NOTIFICATION) | (1 << AudioManager.STREAM_SYSTEM) | (1 << AudioManager.STREAM_SYSTEM_ENFORCED); if (!mContext.getResources().getBoolean( com.android.internal.R.bool.config_voice_capable)) { ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC); db.execSQL("DELETE FROM system WHERE name='" + Settings.System.NOTIFICATIONS_USE_RING_VOLUME + "'"); db.execSQL("INSERT INTO system ('name', 'value') values ('" + Settings.System.NOTIFICATIONS_USE_RING_VOLUME + "', '1')"); } db.execSQL("DELETE FROM system WHERE name='" + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'"); db.execSQL("INSERT INTO system ('name', 'value') values ('" + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '" + String.valueOf(ringerModeAffectedStreams) + "')"); db.setTransactionSuccessful(); } finally { db.endTransaction(); } upgradeVersion = 67; } // *** Remember to update DATABASE_VERSION above! if (upgradeVersion != currentVersion) { Loading Loading @@ -1121,11 +1151,21 @@ public class DatabaseHelper extends SQLiteOpenHelper { loadVibrateSetting(db, false); // By default, only the ring/notification, system and music streams are affected // By default: // - ringtones, notification, system and music streams are affected by ringer mode // on non voice capable devices (tablets) // - ringtones, notification and system streams are affected by ringer mode // on voice capable devices (phones) int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) | (1 << AudioManager.STREAM_NOTIFICATION) | (1 << AudioManager.STREAM_SYSTEM) | (1 << AudioManager.STREAM_SYSTEM_ENFORCED); if (!mContext.getResources().getBoolean( com.android.internal.R.bool.config_voice_capable)) { ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC); } loadSetting(stmt, Settings.System.MODE_RINGER_STREAMS_AFFECTED, (1 << AudioManager.STREAM_RING) | (1 << AudioManager.STREAM_NOTIFICATION) | (1 << AudioManager.STREAM_SYSTEM) | (1 << AudioManager.STREAM_SYSTEM_ENFORCED) | (1 << AudioManager.STREAM_MUSIC)); ringerModeAffectedStreams); loadSetting(stmt, Settings.System.MUTE_STREAMS_AFFECTED, ((1 << AudioManager.STREAM_MUSIC) | Loading Loading @@ -1232,8 +1272,13 @@ public class DatabaseHelper extends SQLiteOpenHelper { R.bool.def_vibrate_in_silent); // Set notification volume to follow ringer volume by default if (mContext.getResources().getBoolean( com.android.internal.R.bool.config_voice_capable)) { loadBooleanSetting(stmt, Settings.System.NOTIFICATIONS_USE_RING_VOLUME, R.bool.def_notifications_use_ring_volume); } else { loadSetting(stmt, Settings.System.NOTIFICATIONS_USE_RING_VOLUME, "1"); } loadIntegerSetting(stmt, Settings.System.POINTER_SPEED, R.integer.def_pointer_speed); Loading