From ff0e747b7a76f221ed7a1062d58a8498a02bd7cb Mon Sep 17 00:00:00 2001 From: junjiez Date: Tue, 27 Nov 2018 16:18:14 +0800 Subject: SnapdraongCamera:Fix CountDown sound Recreate the sound pool when it's null to avoid error. Change-Id: Iefb89c7fe910bdf0fbaa44317c17a74b88350d75 CRs-Fixed: 2356413 --- src/com/android/camera/ui/CountDownView.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/com/android/camera/ui/CountDownView.java b/src/com/android/camera/ui/CountDownView.java index d9d0244e5..f62c99958 100755 --- a/src/com/android/camera/ui/CountDownView.java +++ b/src/com/android/camera/ui/CountDownView.java @@ -99,8 +99,19 @@ public class CountDownView extends FrameLayout { mRemainingSecondsView.clearAnimation(); mRemainingSecondsView.startAnimation(mCountDownAnim); + 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); + } else { + mSoundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0); + } + mBeepOnce = mSoundPool.load(mContext, R.raw.beep_once, 1); + mBeepTwice = mSoundPool.load(mContext, R.raw.beep_twice, 1); + } + // Play sound effect for the last 3 seconds of the countdown - if (mPlaySound) { + if (mPlaySound && mSoundPool != null) { if (newVal == 1) { mSoundPool.play(mBeepTwice, 1.0f, 1.0f, 0, 0, 1.0f); } else if (newVal <= 3) { -- cgit v1.2.3