CommandQueue.java revision 5b9145bf990a9bbf4fdef1739e61ff8c70ec868f
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;
225feceebb892d4cb5777cea3c6174b206705d456bDaniel Sandlerimport android.service.notification.StatusBarNotification;
23de84f0e77ea2bf713d15c290264059a413c2486aJohn Spurlock
240cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratoimport com.android.internal.statusbar.IStatusBar;
250cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratoimport com.android.internal.statusbar.StatusBarIcon;
260cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratoimport com.android.internal.statusbar.StatusBarIconList;
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 {
361d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler    private static final int INDEX_MASK = 0xffff;
371d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler    private static final int MSG_SHIFT  = 16;
381d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler    private static final int MSG_MASK   = 0xffff << MSG_SHIFT;
390cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
401d4d30aebd2c22627131819cabfe95f97def2c83Daniel Sandler    private static final int OP_SET_ICON    = 1;
410cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    private static final int OP_REMOVE_ICON = 2;
420cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
43e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov    private static final int MSG_ICON                       = 1 << MSG_SHIFT;
44e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov    private static final int MSG_ADD_NOTIFICATION           = 2 << MSG_SHIFT;
45e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov    private static final int MSG_UPDATE_NOTIFICATION        = 3 << MSG_SHIFT;
46e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov    private static final int MSG_REMOVE_NOTIFICATION        = 4 << MSG_SHIFT;
47e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov    private static final int MSG_DISABLE                    = 5 << MSG_SHIFT;
48e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov    private static final int MSG_EXPAND_NOTIFICATIONS       = 6 << MSG_SHIFT;
4911cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler    private static final int MSG_COLLAPSE_PANELS            = 7 << MSG_SHIFT;
5011cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler    private static final int MSG_EXPAND_SETTINGS            = 8 << MSG_SHIFT;
5111cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler    private static final int MSG_SET_SYSTEMUI_VISIBILITY    = 9 << MSG_SHIFT;
5211cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler    private static final int MSG_TOP_APP_WINDOW_CHANGED     = 10 << MSG_SHIFT;
5311cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler    private static final int MSG_SHOW_IME_BUTTON            = 11 << MSG_SHIFT;
5411cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler    private static final int MSG_SET_HARD_KEYBOARD_STATUS   = 12 << MSG_SHIFT;
5511cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler    private static final int MSG_TOGGLE_RECENT_APPS         = 13 << MSG_SHIFT;
5611cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler    private static final int MSG_PRELOAD_RECENT_APPS        = 14 << MSG_SHIFT;
5711cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler    private static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 15 << MSG_SHIFT;
5811cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler    private static final int MSG_SET_NAVIGATION_ICON_HINTS  = 16 << MSG_SHIFT;
599764218ff979f735aee2f1189e3547d5f3b02f83John Spurlock    private static final int MSG_SET_WINDOW_STATE           = 17 << MSG_SHIFT;
60328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler
619a720f5eb6c67b581df22f4ecb498cebb459babeJim Miller    public static final int FLAG_EXCLUDE_NONE = 0;
629a720f5eb6c67b581df22f4ecb498cebb459babeJim Miller    public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
639a720f5eb6c67b581df22f4ecb498cebb459babeJim Miller    public static final int FLAG_EXCLUDE_RECENTS_PANEL = 1 << 1;
649a720f5eb6c67b581df22f4ecb498cebb459babeJim Miller    public static final int FLAG_EXCLUDE_NOTIFICATION_PANEL = 1 << 2;
659a720f5eb6c67b581df22f4ecb498cebb459babeJim Miller    public static final int FLAG_EXCLUDE_INPUT_METHODS_PANEL = 1 << 3;
669a720f5eb6c67b581df22f4ecb498cebb459babeJim Miller    public static final int FLAG_EXCLUDE_COMPAT_MODE_PANEL = 1 << 4;
679a720f5eb6c67b581df22f4ecb498cebb459babeJim Miller
680cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    private StatusBarIconList mList;
690cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    private Callbacks mCallbacks;
700cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    private Handler mHandler = new H();
710cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
72a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    private class NotificationQueueEntry {
73a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        IBinder key;
74a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        StatusBarNotification notification;
75a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    }
76a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato
770cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    /**
780cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato     * These methods are called back on the main thread.
790cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato     */
800cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public interface Callbacks {
810cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon);
820cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        public void updateIcon(String slot, int index, int viewIndex,
830cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                StatusBarIcon old, StatusBarIcon icon);
840cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        public void removeIcon(String slot, int index, int viewIndex);
85a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        public void addNotification(IBinder key, StatusBarNotification notification);
86a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        public void updateNotification(IBinder key, StatusBarNotification notification);
87a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        public void removeNotification(IBinder key);
88f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato        public void disable(int state);
8911cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler        public void animateExpandNotificationsPanel();
9011cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler        public void animateCollapsePanels(int flags);
9111cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler        public void animateExpandSettingsPanel();
923a3a6cfd8ec12208ca75c0d0d871d19d76c34194Dianne Hackborn        public void setSystemUiVisibility(int vis, int mask);
937d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn        public void topAppWindowChanged(boolean visible);
94857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato        public void setImeWindowStatus(IBinder token, int vis, int backDisposition);
952992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown        public void setHardKeyboardStatus(boolean available, boolean enabled);
963b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka        public void toggleRecentApps();
977f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka        public void preloadRecentApps();
98e898ac59db04d8ab0762180ca8ec7cea1347aa09Jim Miller        public void showSearchPanel();
99e898ac59db04d8ab0762180ca8ec7cea1347aa09Jim Miller        public void hideSearchPanel();
1007f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka        public void cancelPreloadRecentApps();
101328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler        public void setNavigationIconHints(int hints);
1029764218ff979f735aee2f1189e3547d5f3b02f83John Spurlock        public void setWindowState(int window, int state);
1030cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
1040cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
1050cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public CommandQueue(Callbacks callbacks, StatusBarIconList list) {
1060cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        mCallbacks = callbacks;
1070cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        mList = list;
1080cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
1090cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
1100cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public void setIcon(int index, StatusBarIcon icon) {
1110cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        synchronized (mList) {
1120cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            int what = MSG_ICON | index;
1130cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            mHandler.removeMessages(what);
1140cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            mHandler.obtainMessage(what, OP_SET_ICON, 0, icon.clone()).sendToTarget();
1150cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        }
1160cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
1170cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
1180cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public void removeIcon(int index) {
1190cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        synchronized (mList) {
1200cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            int what = MSG_ICON | index;
1210cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            mHandler.removeMessages(what);
1220cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            mHandler.obtainMessage(what, OP_REMOVE_ICON, 0, null).sendToTarget();
1230cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        }
1240cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
1250cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
126a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    public void addNotification(IBinder key, StatusBarNotification notification) {
127a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        synchronized (mList) {
128a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            NotificationQueueEntry ne = new NotificationQueueEntry();
129a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            ne.key = key;
130a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            ne.notification = notification;
131a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            mHandler.obtainMessage(MSG_ADD_NOTIFICATION, 0, 0, ne).sendToTarget();
132a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        }
133a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    }
134a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato
135a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    public void updateNotification(IBinder key, StatusBarNotification notification) {
136a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        synchronized (mList) {
137a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            NotificationQueueEntry ne = new NotificationQueueEntry();
138a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            ne.key = key;
139a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            ne.notification = notification;
140a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            mHandler.obtainMessage(MSG_UPDATE_NOTIFICATION, 0, 0, ne).sendToTarget();
141a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        }
142a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    }
143a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato
144a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    public void removeNotification(IBinder key) {
145a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        synchronized (mList) {
146a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            mHandler.obtainMessage(MSG_REMOVE_NOTIFICATION, 0, 0, key).sendToTarget();
147a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        }
148a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    }
149a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato
150f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato    public void disable(int state) {
151f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato        synchronized (mList) {
152f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato            mHandler.removeMessages(MSG_DISABLE);
153f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato            mHandler.obtainMessage(MSG_DISABLE, state, 0, null).sendToTarget();
154f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato        }
155f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato    }
156f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato
15711cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler    public void animateExpandNotificationsPanel() {
158e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov        synchronized (mList) {
159e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov            mHandler.removeMessages(MSG_EXPAND_NOTIFICATIONS);
160e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov            mHandler.sendEmptyMessage(MSG_EXPAND_NOTIFICATIONS);
161e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov        }
162e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov    }
163e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov
16411cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler    public void animateCollapsePanels() {
1654762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato        synchronized (mList) {
16611cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler            mHandler.removeMessages(MSG_COLLAPSE_PANELS);
16711cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler            mHandler.sendEmptyMessage(MSG_COLLAPSE_PANELS);
1684762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato        }
1694762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato    }
1704762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato
17111cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler    public void animateExpandSettingsPanel() {
172e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov        synchronized (mList) {
17311cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler            mHandler.removeMessages(MSG_EXPAND_SETTINGS);
17411cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler            mHandler.sendEmptyMessage(MSG_EXPAND_SETTINGS);
1754762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato        }
1764762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato    }
1774762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato
1783a3a6cfd8ec12208ca75c0d0d871d19d76c34194Dianne Hackborn    public void setSystemUiVisibility(int vis, int mask) {
1799305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato        synchronized (mList) {
18060ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler            mHandler.removeMessages(MSG_SET_SYSTEMUI_VISIBILITY);
1813a3a6cfd8ec12208ca75c0d0d871d19d76c34194Dianne Hackborn            mHandler.obtainMessage(MSG_SET_SYSTEMUI_VISIBILITY, vis, mask, null).sendToTarget();
1829305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato        }
1839305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato    }
1849305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato
1857d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn    public void topAppWindowChanged(boolean menuVisible) {
186e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler        synchronized (mList) {
1877d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn            mHandler.removeMessages(MSG_TOP_APP_WINDOW_CHANGED);
1887d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn            mHandler.obtainMessage(MSG_TOP_APP_WINDOW_CHANGED, menuVisible ? 1 : 0, 0,
1897d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn                    null).sendToTarget();
190e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler        }
191e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler    }
192e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler
193857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato    public void setImeWindowStatus(IBinder token, int vis, int backDisposition) {
19406487a58be22b100daf3f950b9a1d25c3ea42aa2satok        synchronized (mList) {
19506487a58be22b100daf3f950b9a1d25c3ea42aa2satok            mHandler.removeMessages(MSG_SHOW_IME_BUTTON);
196857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato            mHandler.obtainMessage(MSG_SHOW_IME_BUTTON, vis, backDisposition, token)
197857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato                    .sendToTarget();
19806487a58be22b100daf3f950b9a1d25c3ea42aa2satok        }
19906487a58be22b100daf3f950b9a1d25c3ea42aa2satok    }
20006487a58be22b100daf3f950b9a1d25c3ea42aa2satok
2012992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown    public void setHardKeyboardStatus(boolean available, boolean enabled) {
2022992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown        synchronized (mList) {
2032992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown            mHandler.removeMessages(MSG_SET_HARD_KEYBOARD_STATUS);
2042992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown            mHandler.obtainMessage(MSG_SET_HARD_KEYBOARD_STATUS,
2052992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown                    available ? 1 : 0, enabled ? 1 : 0).sendToTarget();
2062992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown        }
2072992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown    }
2082992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown
2093b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka    public void toggleRecentApps() {
2103b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka        synchronized (mList) {
2113b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka            mHandler.removeMessages(MSG_TOGGLE_RECENT_APPS);
2123b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka            mHandler.obtainMessage(MSG_TOGGLE_RECENT_APPS, 0, 0, null).sendToTarget();
2133b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka        }
2143b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka    }
2153b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka
2167f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka    public void preloadRecentApps() {
2177f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka        synchronized (mList) {
2187f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka            mHandler.removeMessages(MSG_PRELOAD_RECENT_APPS);
2197f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka            mHandler.obtainMessage(MSG_PRELOAD_RECENT_APPS, 0, 0, null).sendToTarget();
2207f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka        }
2217f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka    }
2227f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka
2237f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka    public void cancelPreloadRecentApps() {
2247f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka        synchronized (mList) {
2257f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka            mHandler.removeMessages(MSG_CANCEL_PRELOAD_RECENT_APPS);
2267f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka            mHandler.obtainMessage(MSG_CANCEL_PRELOAD_RECENT_APPS, 0, 0, null).sendToTarget();
2277f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka        }
2287f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka    }
2297f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka
230328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler    public void setNavigationIconHints(int hints) {
231328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler        synchronized (mList) {
232328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler            mHandler.removeMessages(MSG_SET_NAVIGATION_ICON_HINTS);
233328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler            mHandler.obtainMessage(MSG_SET_NAVIGATION_ICON_HINTS, hints, 0, null).sendToTarget();
234328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler        }
235328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler    }
236328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler
2379764218ff979f735aee2f1189e3547d5f3b02f83John Spurlock    public void setWindowState(int window, int state) {
2389764218ff979f735aee2f1189e3547d5f3b02f83John Spurlock        synchronized (mList) {
2395b9145bf990a9bbf4fdef1739e61ff8c70ec868fJohn Spurlock            // don't coalesce these
2409764218ff979f735aee2f1189e3547d5f3b02f83John Spurlock            mHandler.obtainMessage(MSG_SET_WINDOW_STATE, window, state, null).sendToTarget();
2419764218ff979f735aee2f1189e3547d5f3b02f83John Spurlock        }
2429764218ff979f735aee2f1189e3547d5f3b02f83John Spurlock    }
2439764218ff979f735aee2f1189e3547d5f3b02f83John Spurlock
2440cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    private final class H extends Handler {
2450cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        public void handleMessage(Message msg) {
246f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato            final int what = msg.what & MSG_MASK;
24766d7d01ed91968f4ed2e2669fd306aa2af61cd16Joe Onorato            switch (what) {
2480cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                case MSG_ICON: {
249f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato                    final int index = msg.what & INDEX_MASK;
250f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato                    final int viewIndex = mList.getViewIndex(index);
2510cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                    switch (msg.arg1) {
2520cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                        case OP_SET_ICON: {
2530cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            StatusBarIcon icon = (StatusBarIcon)msg.obj;
2540cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            StatusBarIcon old = mList.getIcon(index);
2550cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            if (old == null) {
2560cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                                mList.setIcon(index, icon);
2570cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                                mCallbacks.addIcon(mList.getSlot(index), index, viewIndex, icon);
2580cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            } else {
2590cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                                mList.setIcon(index, icon);
2600cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                                mCallbacks.updateIcon(mList.getSlot(index), index, viewIndex,
2610cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                                        old, icon);
2620cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            }
2630cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            break;
2640cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                        }
2650cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                        case OP_REMOVE_ICON:
266795f2840b4a70bf188c2f24c8c06f73a492b338cJoe Onorato                            if (mList.getIcon(index) != null) {
267795f2840b4a70bf188c2f24c8c06f73a492b338cJoe Onorato                                mList.removeIcon(index);
268795f2840b4a70bf188c2f24c8c06f73a492b338cJoe Onorato                                mCallbacks.removeIcon(mList.getSlot(index), index, viewIndex);
269795f2840b4a70bf188c2f24c8c06f73a492b338cJoe Onorato                            }
2700cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            break;
2710cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                    }
2720cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                    break;
273f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato                }
274a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                case MSG_ADD_NOTIFICATION: {
275a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    final NotificationQueueEntry ne = (NotificationQueueEntry)msg.obj;
276a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    mCallbacks.addNotification(ne.key, ne.notification);
277a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    break;
278a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                }
279a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                case MSG_UPDATE_NOTIFICATION: {
280a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    final NotificationQueueEntry ne = (NotificationQueueEntry)msg.obj;
281a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    mCallbacks.updateNotification(ne.key, ne.notification);
282a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    break;
283a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                }
284a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                case MSG_REMOVE_NOTIFICATION: {
285a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    mCallbacks.removeNotification((IBinder)msg.obj);
286a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    break;
287a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                }
288f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato                case MSG_DISABLE:
289f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato                    mCallbacks.disable(msg.arg1);
290f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato                    break;
291e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov                case MSG_EXPAND_NOTIFICATIONS:
29211cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler                    mCallbacks.animateExpandNotificationsPanel();
293e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov                    break;
29411cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler                case MSG_COLLAPSE_PANELS:
29511cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler                    mCallbacks.animateCollapsePanels(0);
296e20a177d3f147f3011647c3bdab401f90b2c5d1dSvetoslav Ganov                    break;
29711cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler                case MSG_EXPAND_SETTINGS:
29811cf178100e71d3f9f34ab5865e03a277c5eadaaDaniel Sandler                    mCallbacks.animateExpandSettingsPanel();
2999305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato                    break;
30060ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler                case MSG_SET_SYSTEMUI_VISIBILITY:
3013a3a6cfd8ec12208ca75c0d0d871d19d76c34194Dianne Hackborn                    mCallbacks.setSystemUiVisibility(msg.arg1, msg.arg2);
3029305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato                    break;
3037d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn                case MSG_TOP_APP_WINDOW_CHANGED:
3047d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn                    mCallbacks.topAppWindowChanged(msg.arg1 != 0);
305e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler                    break;
30606487a58be22b100daf3f950b9a1d25c3ea42aa2satok                case MSG_SHOW_IME_BUTTON:
307857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato                    mCallbacks.setImeWindowStatus((IBinder)msg.obj, msg.arg1, msg.arg2);
30806487a58be22b100daf3f950b9a1d25c3ea42aa2satok                    break;
3092992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown                case MSG_SET_HARD_KEYBOARD_STATUS:
3102992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown                    mCallbacks.setHardKeyboardStatus(msg.arg1 != 0, msg.arg2 != 0);
3112992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown                    break;
3123b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka                case MSG_TOGGLE_RECENT_APPS:
3133b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka                    mCallbacks.toggleRecentApps();
3143b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka                    break;
3157f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka                case MSG_PRELOAD_RECENT_APPS:
3167f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka                    mCallbacks.preloadRecentApps();
3177f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka                    break;
3187f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka                case MSG_CANCEL_PRELOAD_RECENT_APPS:
3197f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka                    mCallbacks.cancelPreloadRecentApps();
3207f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka                    break;
321328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler                case MSG_SET_NAVIGATION_ICON_HINTS:
322328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler                    mCallbacks.setNavigationIconHints(msg.arg1);
323328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler                    break;
3249764218ff979f735aee2f1189e3547d5f3b02f83John Spurlock                case MSG_SET_WINDOW_STATE:
3259764218ff979f735aee2f1189e3547d5f3b02f83John Spurlock                    mCallbacks.setWindowState(msg.arg1, msg.arg2);
3269764218ff979f735aee2f1189e3547d5f3b02f83John Spurlock                    break;
3270cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            }
3280cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        }
3290cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
3300cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato}
3310cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
332