From 8accebf97309efc01abb3dd35195facae5f64b04 Mon Sep 17 00:00:00 2001 From: Marvin Ramin Date: Fri, 26 Jun 2020 18:22:35 +0200 Subject: [PATCH] Clear calling identify when persisting volume behavior External callers won't have required permissions to persist the Settings. Bug: 159994127 Test: manaul Change-Id: I7d5b01467052ad06e2204b96430def9fc9f939c6 --- .../java/com/android/server/audio/AudioService.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index b32782a4a1a7a..8ecd102f81989 100755 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -9002,10 +9002,15 @@ public class AudioService extends IAudioService.Stub if (DEBUG_VOL) { Log.d(TAG, "Persisting Volume Behavior for DeviceType: " + deviceType); } - System.putIntForUser(mContentResolver, - getSettingsNameForDeviceVolumeBehavior(deviceType), - deviceVolumeBehavior, - UserHandle.USER_CURRENT); + long callingIdentity = Binder.clearCallingIdentity(); + try { + System.putIntForUser(mContentResolver, + getSettingsNameForDeviceVolumeBehavior(deviceType), + deviceVolumeBehavior, + UserHandle.USER_CURRENT); + } finally { + Binder.restoreCallingIdentity(callingIdentity); + } } @AudioManager.DeviceVolumeBehaviorState