diff options
author | John Spurlock <jspurlock@google.com> | 2014-12-23 16:14:44 -0500 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2014-12-23 16:14:44 -0500 |
commit | af88a19165a1de77948d58b2692c9a7e13712a59 (patch) | |
tree | 524e6cedb1d5518bc7438aa88deb4e98863a92c9 /media | |
parent | 2c8c47daefc881c5603689be39b10cb93a0cabdf (diff) | |
download | frameworks_base-af88a19165a1de77948d58b2692c9a7e13712a59.zip frameworks_base-af88a19165a1de77948d58b2692c9a7e13712a59.tar.gz frameworks_base-af88a19165a1de77948d58b2692c9a7e13712a59.tar.bz2 |
Audio Policy: Clear calling identity for all paths setting ringer mode.
For proper appops bookkeeping and zen setting changes.
Bug: 18832923
Change-Id: Ic029d3226458ca1a9229a0bc5726bedd5e117ad7
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/AudioService.java | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 1c10422..f8688da 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -1841,22 +1841,12 @@ public class AudioService extends IAudioService.Stub { } public void setRingerModeExternal(int ringerMode, String caller) { - final long identity = Binder.clearCallingIdentity(); - try { - setRingerMode(ringerMode, caller, true /*external*/); - } finally { - Binder.restoreCallingIdentity(identity); - } + setRingerMode(ringerMode, caller, true /*external*/); } public void setRingerModeInternal(int ringerMode, String caller) { enforceSelfOrSystemUI("setRingerModeInternal"); - final long identity = Binder.clearCallingIdentity(); - try { - setRingerMode(ringerMode, caller, false /*external*/); - } finally { - Binder.restoreCallingIdentity(identity); - } + setRingerMode(ringerMode, caller, false /*external*/); } private void setRingerMode(int ringerMode, String caller, boolean external) { @@ -1870,28 +1860,33 @@ public class AudioService extends IAudioService.Stub { if ((ringerMode == AudioManager.RINGER_MODE_VIBRATE) && !mHasVibrator) { ringerMode = AudioManager.RINGER_MODE_SILENT; } - 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); + final long identity = Binder.clearCallingIdentity(); + try { + 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); } + } finally { + Binder.restoreCallingIdentity(identity); } } |