10cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato/* 20cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * Copyright (C) 2010 The Android Open Source Project 30cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * 40cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * Licensed under the Apache License, Version 2.0 (the "License"); 50cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * you may not use this file except in compliance with the License. 60cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * You may obtain a copy of the License at 70cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * 80cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * http://www.apache.org/licenses/LICENSE-2.0 90cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * 100cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * Unless required by applicable law or agreed to in writing, software 110cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * distributed under the License is distributed on an "AS IS" BASIS, 120cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * See the License for the specific language governing permissions and 140cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * limitations under the License. 150cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato */ 160cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 1779de0c550037a5328bbc7f4fddaf02f192a5c283Joe Onoratopackage com.android.systemui.statusbar; 180cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 190cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratoimport android.os.Handler; 20a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onoratoimport android.os.IBinder; 210cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratoimport android.os.Message; 220cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 230cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratoimport com.android.internal.statusbar.IStatusBar; 240cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratoimport com.android.internal.statusbar.StatusBarIcon; 250cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratoimport com.android.internal.statusbar.StatusBarIconList; 26a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onoratoimport com.android.internal.statusbar.StatusBarNotification; 270cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 28f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato/** 29f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato * This class takes the functions from IStatusBar that come in on 30f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato * binder pool threads and posts messages to get them onto the main 31f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato * thread, and calls onto Callbacks. It also takes care of 324762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato * coalescing these calls so they don't stack up. For the calls 334762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato * are coalesced, note that they are all idempotent. 34f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato */ 35808182dc874e93582da38d013a4a790d6bc08fc9Joe Onoratopublic class CommandQueue extends IStatusBar.Stub { 36514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato private static final String TAG = "StatusBar.CommandQueue"; 370cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 381d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int INDEX_MASK = 0xffff; 391d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int MSG_SHIFT = 16; 401d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int MSG_MASK = 0xffff << MSG_SHIFT; 410cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 421d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 431d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int MSG_ICON = 1 << MSG_SHIFT; 441d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int OP_SET_ICON = 1; 450cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato private static final int OP_REMOVE_ICON = 2; 460cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 471d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int MSG_ADD_NOTIFICATION = 2 << MSG_SHIFT; 481d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int MSG_UPDATE_NOTIFICATION = 3 << MSG_SHIFT; 491d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int MSG_REMOVE_NOTIFICATION = 4 << MSG_SHIFT; 501d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 511d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int MSG_DISABLE = 5 << MSG_SHIFT; 52f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato 531d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int MSG_SET_VISIBILITY = 6 << MSG_SHIFT; 541d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int OP_EXPAND = 1; 551d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int OP_COLLAPSE = 2; 56a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato 5760ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler private static final int MSG_SET_SYSTEMUI_VISIBILITY = 7 << MSG_SHIFT; 584762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato 593fe9cc5ea6a9e1acd52144c8ae6cb0492dba34baDianne Hackborn private static final int MSG_TOP_APP_WINDOW_CHANGED = 8 << MSG_SHIFT; 601d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int MSG_SHOW_IME_BUTTON = 9 << MSG_SHIFT; 611d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler private static final int MSG_SET_HARD_KEYBOARD_STATUS = 10 << MSG_SHIFT; 621d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler 63df89e65bf0fcc651d20b208c8d8d0b848fb43418Dianne Hackborn private static final int MSG_TOGGLE_RECENT_APPS = 11 << MSG_SHIFT; 649305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato 650cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato private StatusBarIconList mList; 660cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato private Callbacks mCallbacks; 670cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato private Handler mHandler = new H(); 680cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 69a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato private class NotificationQueueEntry { 70a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato IBinder key; 71a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato StatusBarNotification notification; 72a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato } 73a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato 740cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato /** 750cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * These methods are called back on the main thread. 760cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato */ 770cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public interface Callbacks { 780cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon); 790cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public void updateIcon(String slot, int index, int viewIndex, 800cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato StatusBarIcon old, StatusBarIcon icon); 810cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public void removeIcon(String slot, int index, int viewIndex); 82a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato public void addNotification(IBinder key, StatusBarNotification notification); 83a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato public void updateNotification(IBinder key, StatusBarNotification notification); 84a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato public void removeNotification(IBinder key); 85f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato public void disable(int state); 864762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato public void animateExpand(); 874762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato public void animateCollapse(); 8860ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler public void setSystemUiVisibility(int vis); 897d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn public void topAppWindowChanged(boolean visible); 90857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato public void setImeWindowStatus(IBinder token, int vis, int backDisposition); 912992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown public void setHardKeyboardStatus(boolean available, boolean enabled); 923b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public void toggleRecentApps(); 930cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 940cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 950cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public CommandQueue(Callbacks callbacks, StatusBarIconList list) { 960cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato mCallbacks = callbacks; 970cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato mList = list; 980cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 990cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 1000cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public void setIcon(int index, StatusBarIcon icon) { 1010cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato synchronized (mList) { 1020cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato int what = MSG_ICON | index; 1030cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato mHandler.removeMessages(what); 1040cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato mHandler.obtainMessage(what, OP_SET_ICON, 0, icon.clone()).sendToTarget(); 1050cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 1060cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 1070cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 1080cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public void removeIcon(int index) { 1090cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato synchronized (mList) { 1100cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato int what = MSG_ICON | index; 1110cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato mHandler.removeMessages(what); 1120cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato mHandler.obtainMessage(what, OP_REMOVE_ICON, 0, null).sendToTarget(); 1130cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 1140cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 1150cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 116a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato public void addNotification(IBinder key, StatusBarNotification notification) { 117a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato synchronized (mList) { 118a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato NotificationQueueEntry ne = new NotificationQueueEntry(); 119a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato ne.key = key; 120a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato ne.notification = notification; 121a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato mHandler.obtainMessage(MSG_ADD_NOTIFICATION, 0, 0, ne).sendToTarget(); 122a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato } 123a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato } 124a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato 125a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato public void updateNotification(IBinder key, StatusBarNotification notification) { 126a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato synchronized (mList) { 127a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato NotificationQueueEntry ne = new NotificationQueueEntry(); 128a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato ne.key = key; 129a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato ne.notification = notification; 130a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato mHandler.obtainMessage(MSG_UPDATE_NOTIFICATION, 0, 0, ne).sendToTarget(); 131a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato } 132a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato } 133a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato 134a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato public void removeNotification(IBinder key) { 135a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato synchronized (mList) { 136a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato mHandler.obtainMessage(MSG_REMOVE_NOTIFICATION, 0, 0, key).sendToTarget(); 137a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato } 138a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato } 139a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato 140f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato public void disable(int state) { 141f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato synchronized (mList) { 142f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato mHandler.removeMessages(MSG_DISABLE); 143f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato mHandler.obtainMessage(MSG_DISABLE, state, 0, null).sendToTarget(); 144f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato } 145f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato } 146f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato 1474762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato public void animateExpand() { 1484762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato synchronized (mList) { 1494762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato mHandler.removeMessages(MSG_SET_VISIBILITY); 1504762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato mHandler.obtainMessage(MSG_SET_VISIBILITY, OP_EXPAND, 0, null).sendToTarget(); 1514762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato } 1524762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato } 1534762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato 1544762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato public void animateCollapse() { 1554762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato synchronized (mList) { 1564762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato mHandler.removeMessages(MSG_SET_VISIBILITY); 1574762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato mHandler.obtainMessage(MSG_SET_VISIBILITY, OP_COLLAPSE, 0, null).sendToTarget(); 1584762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato } 1594762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato } 1604762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato 16160ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler public void setSystemUiVisibility(int vis) { 1629305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato synchronized (mList) { 16360ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler mHandler.removeMessages(MSG_SET_SYSTEMUI_VISIBILITY); 16460ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler mHandler.obtainMessage(MSG_SET_SYSTEMUI_VISIBILITY, vis, 0, null).sendToTarget(); 1659305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato } 1669305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato } 1679305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato 1687d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn public void topAppWindowChanged(boolean menuVisible) { 169e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler synchronized (mList) { 1707d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn mHandler.removeMessages(MSG_TOP_APP_WINDOW_CHANGED); 1717d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn mHandler.obtainMessage(MSG_TOP_APP_WINDOW_CHANGED, menuVisible ? 1 : 0, 0, 1727d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn null).sendToTarget(); 173e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler } 174e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler } 175e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler 176857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { 17706487a58be22b100daf3f950b9a1d25c3ea42aa2satok synchronized (mList) { 17806487a58be22b100daf3f950b9a1d25c3ea42aa2satok mHandler.removeMessages(MSG_SHOW_IME_BUTTON); 179857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato mHandler.obtainMessage(MSG_SHOW_IME_BUTTON, vis, backDisposition, token) 180857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato .sendToTarget(); 18106487a58be22b100daf3f950b9a1d25c3ea42aa2satok } 18206487a58be22b100daf3f950b9a1d25c3ea42aa2satok } 18306487a58be22b100daf3f950b9a1d25c3ea42aa2satok 1842992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown public void setHardKeyboardStatus(boolean available, boolean enabled) { 1852992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown synchronized (mList) { 1862992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown mHandler.removeMessages(MSG_SET_HARD_KEYBOARD_STATUS); 1872992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown mHandler.obtainMessage(MSG_SET_HARD_KEYBOARD_STATUS, 1882992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown available ? 1 : 0, enabled ? 1 : 0).sendToTarget(); 1892992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown } 1902992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown } 1912992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown 1923b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka public void toggleRecentApps() { 1933b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka synchronized (mList) { 1943b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.removeMessages(MSG_TOGGLE_RECENT_APPS); 1953b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mHandler.obtainMessage(MSG_TOGGLE_RECENT_APPS, 0, 0, null).sendToTarget(); 1963b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 1973b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka } 1983b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka 1990cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato private final class H extends Handler { 2000cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public void handleMessage(Message msg) { 201f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato final int what = msg.what & MSG_MASK; 20266d7d01ed91968f4ed2e2669fd306aa2af61cd16Joe Onorato switch (what) { 2030cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato case MSG_ICON: { 204f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato final int index = msg.what & INDEX_MASK; 205f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato final int viewIndex = mList.getViewIndex(index); 2060cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato switch (msg.arg1) { 2070cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato case OP_SET_ICON: { 2080cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato StatusBarIcon icon = (StatusBarIcon)msg.obj; 2090cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato StatusBarIcon old = mList.getIcon(index); 2100cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato if (old == null) { 2110cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato mList.setIcon(index, icon); 2120cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato mCallbacks.addIcon(mList.getSlot(index), index, viewIndex, icon); 2130cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } else { 2140cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato mList.setIcon(index, icon); 2150cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato mCallbacks.updateIcon(mList.getSlot(index), index, viewIndex, 2160cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato old, icon); 2170cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 2180cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato break; 2190cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 2200cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato case OP_REMOVE_ICON: 221795f2840b4a70bf188c2f24c8c06f73a492b338cJoe Onorato if (mList.getIcon(index) != null) { 222795f2840b4a70bf188c2f24c8c06f73a492b338cJoe Onorato mList.removeIcon(index); 223795f2840b4a70bf188c2f24c8c06f73a492b338cJoe Onorato mCallbacks.removeIcon(mList.getSlot(index), index, viewIndex); 224795f2840b4a70bf188c2f24c8c06f73a492b338cJoe Onorato } 2250cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato break; 2260cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 2270cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato break; 228f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato } 229a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato case MSG_ADD_NOTIFICATION: { 230a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato final NotificationQueueEntry ne = (NotificationQueueEntry)msg.obj; 231a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato mCallbacks.addNotification(ne.key, ne.notification); 232a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato break; 233a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato } 234a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato case MSG_UPDATE_NOTIFICATION: { 235a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato final NotificationQueueEntry ne = (NotificationQueueEntry)msg.obj; 236a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato mCallbacks.updateNotification(ne.key, ne.notification); 237a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato break; 238a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato } 239a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato case MSG_REMOVE_NOTIFICATION: { 240a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato mCallbacks.removeNotification((IBinder)msg.obj); 241a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato break; 242a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato } 243f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato case MSG_DISABLE: 244f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato mCallbacks.disable(msg.arg1); 245f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato break; 2464762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato case MSG_SET_VISIBILITY: 2474762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato if (msg.arg1 == OP_EXPAND) { 2484762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato mCallbacks.animateExpand(); 2494762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato } else { 2504762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato mCallbacks.animateCollapse(); 2514762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato } 2529305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato break; 25360ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler case MSG_SET_SYSTEMUI_VISIBILITY: 25460ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler mCallbacks.setSystemUiVisibility(msg.arg1); 2559305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato break; 2567d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn case MSG_TOP_APP_WINDOW_CHANGED: 2577d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn mCallbacks.topAppWindowChanged(msg.arg1 != 0); 258e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler break; 25906487a58be22b100daf3f950b9a1d25c3ea42aa2satok case MSG_SHOW_IME_BUTTON: 260857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato mCallbacks.setImeWindowStatus((IBinder)msg.obj, msg.arg1, msg.arg2); 26106487a58be22b100daf3f950b9a1d25c3ea42aa2satok break; 2622992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown case MSG_SET_HARD_KEYBOARD_STATUS: 2632992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown mCallbacks.setHardKeyboardStatus(msg.arg1 != 0, msg.arg2 != 0); 2642992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown break; 2653b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka case MSG_TOGGLE_RECENT_APPS: 2663b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka mCallbacks.toggleRecentApps(); 2673b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka break; 2680cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 2690cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 2700cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 2710cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato} 2720cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 273