diff --git a/services/java/com/android/server/status/StatusBarService.java b/services/java/com/android/server/status/StatusBarService.java index bcaf0a49be3c6..93c8d34312a4b 100644 --- a/services/java/com/android/server/status/StatusBarService.java +++ b/services/java/com/android/server/status/StatusBarService.java @@ -153,6 +153,7 @@ public class StatusBarService extends IStatusBar.Stub StatusBarView mStatusBarView; int mPixelFormat; H mHandler = new H(); + Object mQueueLock = new Object(); ArrayList mQueue = new ArrayList(); NotificationCallbacks mNotificationCallbacks; @@ -440,7 +441,7 @@ public class StatusBarService extends IStatusBar.Stub } private void addPendingOp(int code, IBinder key, IconData data, NotificationData n, int i) { - synchronized (mQueue) { + synchronized (mQueueLock) { PendingOp op = new PendingOp(); op.key = key; op.code = code; @@ -455,7 +456,7 @@ public class StatusBarService extends IStatusBar.Stub } private void addPendingOp(int code, IBinder key, boolean visible) { - synchronized (mQueue) { + synchronized (mQueueLock) { PendingOp op = new PendingOp(); op.key = key; op.code = code; @@ -468,7 +469,7 @@ public class StatusBarService extends IStatusBar.Stub } private void addPendingOp(int code, int integer) { - synchronized (mQueue) { + synchronized (mQueueLock) { PendingOp op = new PendingOp(); op.code = code; op.integer = integer; @@ -557,94 +558,94 @@ public class StatusBarService extends IStatusBar.Stub doRevealAnimation(); return; } - boolean expand = false; + + ArrayList queue; + synchronized (mQueueLock) { + queue = mQueue; + mQueue = new ArrayList(); + } + + boolean wasExpanded = mExpanded; + + // for each one in the queue, find all of the ones with the same key + // and collapse that down into a final op and/or call to setVisibility, etc + boolean expand = wasExpanded; boolean doExpand = false; boolean doDisable = false; int disableWhat = 0; + int N = queue.size(); + while (N > 0) { + PendingOp op = queue.get(0); + boolean doOp = false; + boolean visible = false; + boolean doVisibility = false; + if (op.code == OP_SET_VISIBLE) { + doVisibility = true; + visible = op.visible; + } + else if (op.code == OP_EXPAND) { + doExpand = true; + expand = op.visible; + } + else if (op.code == OP_TOGGLE) { + doExpand = true; + expand = !expand; + } + else { + doOp = true; + } - synchronized (mQueue) { - boolean wasExpanded = mExpanded; - - // for each one in the queue, find all of the ones with the same key - // and collapse that down into a final op and/or call to setVisibility, etc - expand = wasExpanded; - int N = mQueue.size(); - while (N > 0) { - PendingOp op = mQueue.get(0); - boolean doOp = false; - boolean visible = false; - boolean doVisibility = false; - if (op.code == OP_SET_VISIBLE) { - doVisibility = true; - visible = op.visible; - } - else if (op.code == OP_EXPAND) { - doExpand = true; - expand = op.visible; - } - else if (op.code == OP_TOGGLE) { - doExpand = true; - expand = !expand; - } - else { - doOp = true; - } - - if (alwaysHandle(op.code)) { - // coalesce these - for (int i=1; i