summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jean-Michel Trivi <jmtrivi@google.com> 2010-05-05 12:06:12 -0700
committer Android Git Automerger <android-git-automerger@android.com> 2010-05-05 12:06:12 -0700
commit99fb50468c460c29da8541cd69655bd3ff92cb08 (patch)
tree76ff487f5295350b0e180629476ed7530b25f7bf
parent0835f067999ce9c5da1c250e23f8c9814058a4db (diff)
parentfc12b5be2ee49ba2392274d413bd5d759c03c346 (diff)
am fc12b5be: am b5fa4dff: Merge "Fix bug 2594126 Do not crash when ViewRoot is trying to play a UI sound. This CL doesn\'t fix why mView can be null in the first place, but prevents a crash when mView is null and a UI sound is to be played." into froyo
Merge commit 'fc12b5be2ee49ba2392274d413bd5d759c03c346' into kraken * commit 'fc12b5be2ee49ba2392274d413bd5d759c03c346': Fix bug 2594126 Do not crash when ViewRoot is trying to play a UI
-rw-r--r--core/java/android/view/ViewRoot.java46
1 files changed, 26 insertions, 20 deletions
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index c2c57bb00cc6..1daf580308d3 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -2582,27 +2582,33 @@ public final class ViewRoot extends Handler implements ViewParent,
public void playSoundEffect(int effectId) {
checkThread();
- final AudioManager audioManager = getAudioManager();
+ try {
+ final AudioManager audioManager = getAudioManager();
- switch (effectId) {
- case SoundEffectConstants.CLICK:
- audioManager.playSoundEffect(AudioManager.FX_KEY_CLICK);
- return;
- case SoundEffectConstants.NAVIGATION_DOWN:
- audioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_DOWN);
- return;
- case SoundEffectConstants.NAVIGATION_LEFT:
- audioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_LEFT);
- return;
- case SoundEffectConstants.NAVIGATION_RIGHT:
- audioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_RIGHT);
- return;
- case SoundEffectConstants.NAVIGATION_UP:
- audioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_UP);
- return;
- default:
- throw new IllegalArgumentException("unknown effect id " + effectId +
- " not defined in " + SoundEffectConstants.class.getCanonicalName());
+ switch (effectId) {
+ case SoundEffectConstants.CLICK:
+ audioManager.playSoundEffect(AudioManager.FX_KEY_CLICK);
+ return;
+ case SoundEffectConstants.NAVIGATION_DOWN:
+ audioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_DOWN);
+ return;
+ case SoundEffectConstants.NAVIGATION_LEFT:
+ audioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_LEFT);
+ return;
+ case SoundEffectConstants.NAVIGATION_RIGHT:
+ audioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_RIGHT);
+ return;
+ case SoundEffectConstants.NAVIGATION_UP:
+ audioManager.playSoundEffect(AudioManager.FX_FOCUS_NAVIGATION_UP);
+ return;
+ default:
+ throw new IllegalArgumentException("unknown effect id " + effectId +
+ " not defined in " + SoundEffectConstants.class.getCanonicalName());
+ }
+ } catch (IllegalStateException e) {
+ // Exception thrown by getAudioManager() when mView is null
+ Log.e(TAG, "FATAL EXCEPTION when attempting to play sound effect: " + e);
+ e.printStackTrace();
}
}