summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2019-02-28 12:35:21 -0800
committerJean-Michel Trivi <jmtrivi@google.com>2019-02-28 12:35:21 -0800
commitfbae346f30673db84c66849828c4b7fe6868417d (patch)
tree7cdad51dadb926443cc359f0403e929a0b3c6b74
parentb8f322dd105e1ea17cee0c726db0e999eb94cdc6 (diff)
downloadandroid_packages_apps_Camera2-fbae346f30673db84c66849828c4b7fe6868417d.tar.gz
android_packages_apps_Camera2-fbae346f30673db84c66849828c4b7fe6868417d.tar.bz2
android_packages_apps_Camera2-fbae346f30673db84c66849828c4b7fe6868417d.zip
Fix use of deprecated SoundPool API in Camera2 SoundPlayer
Don't use stream types for operations other than volume control Bug: 122901916 Test: verify logcat doesn't show warnings, see bug Change-Id: Id5b4f3b3c56c61a2f00172a470410e0670ce81b4
-rw-r--r--src/com/android/camera/SoundPlayer.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/com/android/camera/SoundPlayer.java b/src/com/android/camera/SoundPlayer.java
index ff3f37f7a..6e76eb535 100644
--- a/src/com/android/camera/SoundPlayer.java
+++ b/src/com/android/camera/SoundPlayer.java
@@ -17,6 +17,7 @@
package com.android.camera;
import android.content.Context;
+import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.SoundPool;
import android.util.SparseIntArray;
@@ -39,8 +40,14 @@ public class SoundPlayer {
*/
public SoundPlayer(Context appContext) {
mAppContext = appContext;
- final int audioType = getAudioTypeForSoundPool();
- mSoundPool = new SoundPool(1 /* max streams */, audioType, 0 /* quality */);
+ mSoundPool = new SoundPool.Builder()
+ .setMaxStreams(1)
+ .setAudioAttributes(new AudioAttributes.Builder()
+ .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
+ .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
+ .setFlags(AudioAttributes.FLAG_AUDIBILITY_ENFORCED)
+ .build())
+ .build();
}
/**
@@ -86,10 +93,4 @@ public class SoundPlayer {
public boolean isReleased() {
return mIsReleased;
}
-
- private static int getAudioTypeForSoundPool() {
- // STREAM_SYSTEM_ENFORCED is hidden API.
- return ApiHelper.getIntFieldIfExists(AudioManager.class,
- "STREAM_SYSTEM_ENFORCED", null, AudioManager.STREAM_RING);
- }
}