diff options
| author | 2023-10-03 08:45:35 -0700 | |
|---|---|---|
| committer | 2023-10-03 19:56:00 +0000 | |
| commit | 7773a42b04a4882a8500c16623d2643c13735a99 (patch) | |
| tree | 5ec60bb4594a945657ee67b6d392a16da128474a | |
| parent | bd33753f8ca84afec595e56c3fc487c8ef4d8b33 (diff) | |
[SettingsProvider] clear binder identity when updating the ringtone cache
Otherwise non-system callers can set the ringtone but cannot update the
ringtone cache. This doesn't affect a normal user journey (user setting Ringtone via the Settings app). It only affects CTS tests and third-party apps that tries to update the system ringtone.
BUG: 297847899
Test: atest android.media.audio.cts.RingtoneManagerTest
Change-Id: I15ed4bd3f9d49b0edeea0c752f37ad8b8e421473
| -rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index e45913c1eb21..b785d6f7f858 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -2034,12 +2034,14 @@ public class SettingsProvider extends ContentProvider { final Uri ringtoneUri = Uri.parse(value); // Stream selected ringtone into cache, so it's available for playback // when CE storage is still locked - try (InputStream in = openRingtone(getContext(), ringtoneUri); - OutputStream out = new FileOutputStream(cacheFile)) { - FileUtils.copy(in, out); - } catch (IOException e) { - Slog.w(LOG_TAG, "Failed to cache ringtone: " + e); - } + Binder.withCleanCallingIdentity(() -> { + try (InputStream in = openRingtone(getContext(), ringtoneUri); + OutputStream out = new FileOutputStream(cacheFile)) { + FileUtils.copy(in, out); + } catch (IOException e) { + Slog.w(LOG_TAG, "Failed to cache ringtone: " + e); + } + }); } return true; } |