Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

disable camera sounds (2/3)

Change-Id: Iaa37bc6790fe32664f8b52178c14fe926ca7d4ce
Signed-off-by: sethyx <sethyx@gmail.com>
  • Loading branch information...
commit f782f01137f9d1578cdd1e6f1bcb739b3d3040b3 1 parent 10d3ee6
@sethyx sethyx authored Gerrit Code Review committed
Showing with 14 additions and 9 deletions.
  1. +14 −9 media/java/android/media/MediaActionSound.java
View
23 media/java/android/media/MediaActionSound.java
@@ -18,6 +18,7 @@
import android.media.AudioManager;
import android.media.SoundPool;
+import android.os.SystemProperties;
import android.util.Log;
/**
@@ -88,6 +89,8 @@
private static final int SOUND_NOT_LOADED = -1;
+ private static final String PROP_CAMERA_SOUND = "persist.sys.camera-sound";
+
/**
* Construct a new MediaActionSound instance. Only a single instance is
* needed for playing any platform media action sound; you do not need a
@@ -156,15 +159,17 @@ public synchronized void load(int soundName) {
* @see #STOP_VIDEO_RECORDING
*/
public synchronized void play(int soundName) {
- if (soundName < 0 || soundName >= SOUND_FILES.length) {
- throw new RuntimeException("Unknown sound requested: " + soundName);
- }
- if (mSoundIds[soundName] == SOUND_NOT_LOADED) {
- mSoundIdToPlay =
- mSoundPool.load(SOUND_FILES[soundName], 1);
- mSoundIds[soundName] = mSoundIdToPlay;
- } else {
- mSoundPool.play(mSoundIds[soundName], 1.0f, 1.0f, 0, 0, 1.0f);
+ if (SystemProperties.getBoolean(PROP_CAMERA_SOUND, true)) {
+ if (soundName < 0 || soundName >= SOUND_FILES.length) {
+ throw new RuntimeException("Unknown sound requested: " + soundName);
+ }
+ if (mSoundIds[soundName] == SOUND_NOT_LOADED) {
+ mSoundIdToPlay =
+ mSoundPool.load(SOUND_FILES[soundName], 1);
+ mSoundIds[soundName] = mSoundIdToPlay;
+ } else {
+ mSoundPool.play(mSoundIds[soundName], 1.0f, 1.0f, 0, 0, 1.0f);
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.