summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2012-05-30 17:29:28 -0700
committerAmith Yamasani <yamasani@google.com>2012-05-30 18:28:08 -0700
commita654986978c870ed33af2ad696cd6e61d9fed489 (patch)
tree93db81789469e2a5732aa3c40da9a88efd78112f /core/java/android
parent5ab6e12b450d13c8eb501001c7a8669826b86ea4 (diff)
downloadframeworks_base-a654986978c870ed33af2ad696cd6e61d9fed489.zip
frameworks_base-a654986978c870ed33af2ad696cd6e61d9fed489.tar.gz
frameworks_base-a654986978c870ed33af2ad696cd6e61d9fed489.tar.bz2
Protect volumepanel slider creation from race condition.
It is possible for 2 different threads to poke the mStreamControls at the same time, causing the monkey bug mentioned in the bug report below. Bug: 6411852 Couldn't think of any other reason Stream type 3 (MUSIC) wouldn't exist in the list. It's possible that a programmatic call came in at the same time as the volume key press. Synchronizing blocks where the mStreamControls are populated and accessed. Change-Id: Ifedec6b0f8bad9634cb9e079fda785c433bdb7a7
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/VolumePanel.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java
index 78984e0..5ffc2c3 100644
--- a/core/java/android/view/VolumePanel.java
+++ b/core/java/android/view/VolumePanel.java
@@ -437,8 +437,10 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
public void postVolumeChanged(int streamType, int flags) {
if (hasMessages(MSG_VOLUME_CHANGED)) return;
- if (mStreamControls == null) {
- createSliders();
+ synchronized (this) {
+ if (mStreamControls == null) {
+ createSliders();
+ }
}
removeMessages(MSG_FREE_RESOURCES);
obtainMessage(MSG_VOLUME_CHANGED, streamType, flags).sendToTarget();
@@ -450,8 +452,10 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
public void postMuteChanged(int streamType, int flags) {
if (hasMessages(MSG_VOLUME_CHANGED)) return;
- if (mStreamControls == null) {
- createSliders();
+ synchronized (this) {
+ if (mStreamControls == null) {
+ createSliders();
+ }
}
removeMessages(MSG_FREE_RESOURCES);
obtainMessage(MSG_MUTE_CHANGED, streamType, flags).sendToTarget();
@@ -471,10 +475,12 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
if (LOGD) Log.d(TAG, "onVolumeChanged(streamType: " + streamType + ", flags: " + flags + ")");
if ((flags & AudioManager.FLAG_SHOW_UI) != 0) {
- if (mActiveStreamType != streamType) {
- reorderSliders(streamType);
+ synchronized (this) {
+ if (mActiveStreamType != streamType) {
+ reorderSliders(streamType);
+ }
+ onShowVolumeChanged(streamType, flags);
}
- onShowVolumeChanged(streamType, flags);
}
if ((flags & AudioManager.FLAG_PLAY_SOUND) != 0 && ! mRingIsSilent) {