diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2019-02-28 12:35:21 -0800 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2019-11-09 22:47:37 +0200 |
commit | 496d5e0052fcb85f3c1053fb585b52fa10fdee88 (patch) | |
tree | c713bc7679ead930028a2b433827211a8f8e6fc6 /src/com/android/camera/SoundClips.java | |
parent | feb3d9fdd62e08b27be4e0c578c90c0f33712947 (diff) | |
download | android_packages_apps_Snap-496d5e0052fcb85f3c1053fb585b52fa10fdee88.tar.gz android_packages_apps_Snap-496d5e0052fcb85f3c1053fb585b52fa10fdee88.tar.bz2 android_packages_apps_Snap-496d5e0052fcb85f3c1053fb585b52fa10fdee88.zip |
Fix use of deprecated SoundPool API in Snap
Don't use stream types for operations other than volume control
[Chippa_a]: Extended for Snap
Bug: 122901916
Test: verify logcat doesn't show warnings, see bug
Change-Id: Id5b4f3b3c56c61a2f00172a470410e0670ce81b4
Signed-off-by: Chippa-a <vusal1372@gmail.com>
Diffstat (limited to 'src/com/android/camera/SoundClips.java')
-rw-r--r-- | src/com/android/camera/SoundClips.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/com/android/camera/SoundClips.java b/src/com/android/camera/SoundClips.java index 8ccd51d4a..812734e2b 100644 --- a/src/com/android/camera/SoundClips.java +++ b/src/com/android/camera/SoundClips.java @@ -18,6 +18,7 @@ package com.android.camera; import android.annotation.TargetApi; import android.content.Context; +import android.media.AudioAttributes; import android.media.AudioManager; import android.media.MediaActionSound; import android.media.SoundPool; @@ -50,12 +51,6 @@ public class SoundClips { } } - public static int getAudioTypeForSoundPool() { - // STREAM_SYSTEM_ENFORCED is hidden API. - return ApiHelper.getIntFieldIfExists(AudioManager.class, - "STREAM_SYSTEM_ENFORCED", null, AudioManager.STREAM_RING); - } - /** * This class implements SoundClips.Player using MediaActionSound, * which exists since API level 16. @@ -136,7 +131,14 @@ public class SoundClips { mSoundIDToPlay = ID_NOT_LOADED; - mSoundPool = new SoundPool(NUM_SOUND_STREAMS, getAudioTypeForSoundPool(), 0); + mSoundPool = new SoundPool.Builder() + .setMaxStreams(NUM_SOUND_STREAMS) + .setAudioAttributes(new AudioAttributes.Builder() + .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) + .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) + .setFlags(AudioAttributes.FLAG_AUDIBILITY_ENFORCED) + .build()) + .build(); mSoundPool.setOnLoadCompleteListener(this); mSoundIDs = new int[SOUND_RES.length]; |