diff options
author | John Spurlock <jspurlock@google.com> | 2014-12-11 11:29:54 -0500 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2014-12-17 12:34:00 -0500 |
commit | 57627794b682235afd60adfb235fee46d32f54e2 (patch) | |
tree | 05bbdb936f2e189c843d592b945b03939a1b212a /media | |
parent | 0de823704d94d9e9e5cceccf4573afed4fd66b28 (diff) | |
download | frameworks_base-57627794b682235afd60adfb235fee46d32f54e2.zip frameworks_base-57627794b682235afd60adfb235fee46d32f54e2.tar.gz frameworks_base-57627794b682235afd60adfb235fee46d32f54e2.tar.bz2 |
Audio policy: Fix deprecated shouldVibrate api.
And apply zen mode immediately to avoid race conditions
in tests.
Bug: 18702149
Change-Id: Iad156a29b9e6a5998e7c2dafa8b79a71447066f9
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/AudioService.java | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index f0150d4..8a543ce 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -1841,12 +1841,22 @@ public class AudioService extends IAudioService.Stub { } public void setRingerModeExternal(int ringerMode, String caller) { - setRingerMode(ringerMode, caller, true /*external*/); + final long identity = Binder.clearCallingIdentity(); + try { + setRingerMode(ringerMode, caller, true /*external*/); + } finally { + Binder.restoreCallingIdentity(identity); + } } public void setRingerModeInternal(int ringerMode, String caller) { enforceSelfOrSystemUI("setRingerModeInternal"); - setRingerMode(ringerMode, caller, false /*external*/); + final long identity = Binder.clearCallingIdentity(); + try { + setRingerMode(ringerMode, caller, false /*external*/); + } finally { + Binder.restoreCallingIdentity(identity); + } } private void setRingerMode(int ringerMode, String caller, boolean external) { @@ -1860,26 +1870,28 @@ public class AudioService extends IAudioService.Stub { if ((ringerMode == AudioManager.RINGER_MODE_VIBRATE) && !mHasVibrator) { ringerMode = AudioManager.RINGER_MODE_SILENT; } - final int ringerModeInternal = getRingerModeInternal(); - final int ringerModeExternal = getRingerModeExternal(); - if (external) { - setRingerModeExt(ringerMode); - if (mRingerModeDelegate != null) { - ringerMode = mRingerModeDelegate.onSetRingerModeExternal(ringerModeExternal, - ringerMode, caller, ringerModeInternal); - } - if (ringerMode != ringerModeInternal) { - setRingerModeInt(ringerMode, true /*persist*/); - } - } else /*internal*/ { - if (ringerMode != ringerModeInternal) { - setRingerModeInt(ringerMode, true /*persist*/); - } - if (mRingerModeDelegate != null) { - ringerMode = mRingerModeDelegate.onSetRingerModeInternal(ringerModeInternal, - ringerMode, caller, ringerModeExternal); + synchronized (mSettingsLock) { + final int ringerModeInternal = getRingerModeInternal(); + final int ringerModeExternal = getRingerModeExternal(); + if (external) { + setRingerModeExt(ringerMode); + if (mRingerModeDelegate != null) { + ringerMode = mRingerModeDelegate.onSetRingerModeExternal(ringerModeExternal, + ringerMode, caller, ringerModeInternal); + } + if (ringerMode != ringerModeInternal) { + setRingerModeInt(ringerMode, true /*persist*/); + } + } else /*internal*/ { + if (ringerMode != ringerModeInternal) { + setRingerModeInt(ringerMode, true /*persist*/); + } + if (mRingerModeDelegate != null) { + ringerMode = mRingerModeDelegate.onSetRingerModeInternal(ringerModeInternal, + ringerMode, caller, ringerModeExternal); + } + setRingerModeExt(ringerMode); } - setRingerModeExt(ringerMode); } } @@ -1968,10 +1980,10 @@ public class AudioService extends IAudioService.Stub { switch (getVibrateSetting(vibrateType)) { case AudioManager.VIBRATE_SETTING_ON: - return getRingerModeInternal() != AudioManager.RINGER_MODE_SILENT; + return getRingerModeExternal() != AudioManager.RINGER_MODE_SILENT; case AudioManager.VIBRATE_SETTING_ONLY_SILENT: - return getRingerModeInternal() == AudioManager.RINGER_MODE_VIBRATE; + return getRingerModeExternal() == AudioManager.RINGER_MODE_VIBRATE; case AudioManager.VIBRATE_SETTING_OFF: // return false, even for incoming calls |