summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2015-11-12 18:19:12 -0800
committerJay Wang <jaywang@codeaurora.org>2015-11-13 14:26:17 -0800
commit9876bd89124c3222214e0a16a0a92291ac51cc7d (patch)
tree4322d3a60ee1ed2f10a1f4576d1d73d527afc7c4
parenta147f0379f75535529a27a5da0974f57aba5a358 (diff)
downloadandroid_packages_apps_Snap-9876bd89124c3222214e0a16a0a92291ac51cc7d.tar.gz
android_packages_apps_Snap-9876bd89124c3222214e0a16a0a92291ac51cc7d.tar.bz2
android_packages_apps_Snap-9876bd89124c3222214e0a16a0a92291ac51cc7d.zip
SnapdragonCamera: Fix the issue SoundPoolThread is not released
Two SoundPool objects are created during onCreate. However, the SoundPool is not released or re-used, properly and app continuously creating the new one. Fixing the issue for shutter button SoundPool by adding the releasing call and changing the call flow so it gets created and released during onPause and onResume. For count down SoundPool, we just re-use the existing SoundPool object instead of creating the new one. CRs-Fixed: 939366 Change-Id: I8ff1d62ce7b0e217df29ded92c9a07b02bf0ffbb
-rw-r--r--src/com/android/camera/PhotoModule.java14
-rw-r--r--src/com/android/camera/ui/CountDownView.java23
2 files changed, 24 insertions, 13 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index d9087a281..d9c468b88 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -519,9 +519,6 @@ public class PhotoModule
brightnessProgressBar.setVisibility(View.INVISIBLE);
Storage.setSaveSDCard(
mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH, "0").equals("1"));
-
- mSoundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
- mRefocusSound = mSoundPool.load(mActivity, R.raw.camera_click_x5, 1);
}
private void initializeControlByIntent() {
@@ -2243,6 +2240,12 @@ public class PhotoModule
Log.v(TAG, "On resume.");
onResumeTasks();
}
+
+ if (mSoundPool == null) {
+ mSoundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
+ mRefocusSound = mSoundPool.load(mActivity, R.raw.camera_click_x5, 1);
+ }
+
mHandler.post(new Runnable(){
@Override
public void run(){
@@ -2320,6 +2323,11 @@ public class PhotoModule
mSensorManager.unregisterListener(this, msensor);
}
+ if (mSoundPool != null) {
+ mSoundPool.release();
+ mSoundPool = null;
+ }
+
Log.d(TAG, "remove idle handleer in onPause");
removeIdleHandler();
}
diff --git a/src/com/android/camera/ui/CountDownView.java b/src/com/android/camera/ui/CountDownView.java
index c8d7174b1..6420fd2c3 100644
--- a/src/com/android/camera/ui/CountDownView.java
+++ b/src/com/android/camera/ui/CountDownView.java
@@ -44,9 +44,9 @@ public class CountDownView extends FrameLayout {
private int mRemainingSecs = 0;
private OnCountDownFinishedListener mListener;
private Animation mCountDownAnim;
- private SoundPool mSoundPool;
- private int mBeepTwice;
- private int mBeepOnce;
+ private static SoundPool mSoundPool;
+ private static int mBeepTwice;
+ private static int mBeepOnce;
private boolean mPlaySound;
private final Handler mHandler = new MainHandler();
@@ -54,14 +54,17 @@ public class CountDownView extends FrameLayout {
super(context, attrs);
mContext = context;
mCountDownAnim = AnimationUtils.loadAnimation(context, R.anim.count_down_exit);
- // Load the beeps
- if (context.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);
+
+ if (mSoundPool == null) {
+ // Load the beeps
+ if (context.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(context, R.raw.beep_once, 1);
+ mBeepTwice = mSoundPool.load(context, R.raw.beep_twice, 1);
}
- mBeepOnce = mSoundPool.load(context, R.raw.beep_once, 1);
- mBeepTwice = mSoundPool.load(context, R.raw.beep_twice, 1);
}
public boolean isCountingDown() {