summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2019-02-28 12:35:21 -0800
committerMichael Bestas <mkbestas@lineageos.org>2019-11-09 22:47:37 +0200
commit496d5e0052fcb85f3c1053fb585b52fa10fdee88 (patch)
treec713bc7679ead930028a2b433827211a8f8e6fc6
parentfeb3d9fdd62e08b27be4e0c578c90c0f33712947 (diff)
downloadandroid_packages_apps_Snap-496d5e0052fcb85f3c1053fb585b52fa10fdee88.zip
android_packages_apps_Snap-496d5e0052fcb85f3c1053fb585b52fa10fdee88.tar.gz
android_packages_apps_Snap-496d5e0052fcb85f3c1053fb585b52fa10fdee88.tar.bz2
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>
-rwxr-xr-xsrc/com/android/camera/PhotoModule.java9
-rw-r--r--src/com/android/camera/SoundClips.java16
-rw-r--r--src/com/android/camera/SoundPlayer.java17
-rwxr-xr-xsrc/com/android/camera/ui/CountDownView.java18
4 files changed, 42 insertions, 18 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 06c7cf6..b713f8f 100755
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -41,6 +41,7 @@ import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.location.Location;
+import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.CameraProfile;
import android.media.SoundPool;
@@ -2659,7 +2660,13 @@ public class PhotoModule
mUI.setSwitcherIndex();
if (mSoundPool == null) {
- mSoundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
+ mSoundPool = new SoundPool.Builder()
+ .setMaxStreams(1)
+ .setAudioAttributes(new AudioAttributes.Builder()
+ .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
+ .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
+ .build())
+ .build();
mRefocusSound = mSoundPool.load(mActivity, R.raw.camera_click_x5, 1);
}
diff --git a/src/com/android/camera/SoundClips.java b/src/com/android/camera/SoundClips.java
index 8ccd51d..812734e 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];
diff --git a/src/com/android/camera/SoundPlayer.java b/src/com/android/camera/SoundPlayer.java
index ff3f37f..6e76eb5 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);
- }
}
diff --git a/src/com/android/camera/ui/CountDownView.java b/src/com/android/camera/ui/CountDownView.java
index 0e1acc0..069d0b3 100755
--- a/src/com/android/camera/ui/CountDownView.java
+++ b/src/com/android/camera/ui/CountDownView.java
@@ -20,6 +20,7 @@ import java.util.Locale;
import android.content.Context;
import android.content.res.Configuration;
+import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Handler;
@@ -62,9 +63,22 @@ public class CountDownView extends FrameLayout {
if (mSoundPool == null) {
// Load the beeps
if (mContext.getResources().getBoolean(R.bool.force_count_down_sound)) {
- mSoundPool = new SoundPool(1, AudioManager.STREAM_SYSTEM_ENFORCED, 0);
+ 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();
} else {
- mSoundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
+ mSoundPool = new SoundPool.Builder()
+ .setMaxStreams(1)
+ .setAudioAttributes(new AudioAttributes.Builder()
+ .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
+ .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
+ .build())
+ .build();
}
mBeepOnce = mSoundPool.load(mContext, R.raw.beep_once, 1);
mBeepTwice = mSoundPool.load(mContext, R.raw.beep_twice, 1);