CommandQueue.java revision 7f2668c8469934ce83a5647977f6e74ab782cf07
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;
647f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka    private static final int MSG_PRELOAD_RECENT_APPS      = 12 << MSG_SHIFT;
657f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka    private static final int MSG_CANCEL_PRELOAD_RECENT_APPS       = 13 << MSG_SHIFT;
669305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato
677f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka    private static final int MSG_SET_NAVIGATION_ICON_HINTS = 14 << MSG_SHIFT;
68328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler
690cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    private StatusBarIconList mList;
700cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    private Callbacks mCallbacks;
710cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    private Handler mHandler = new H();
720cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
73a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    private class NotificationQueueEntry {
74a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        IBinder key;
75a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        StatusBarNotification notification;
76a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    }
77a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato
780cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    /**
790cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato     * These methods are called back on the main thread.
800cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato     */
810cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public interface Callbacks {
820cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon);
830cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        public void updateIcon(String slot, int index, int viewIndex,
840cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                StatusBarIcon old, StatusBarIcon icon);
850cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        public void removeIcon(String slot, int index, int viewIndex);
86a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        public void addNotification(IBinder key, StatusBarNotification notification);
87a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        public void updateNotification(IBinder key, StatusBarNotification notification);
88a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        public void removeNotification(IBinder key);
89f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato        public void disable(int state);
904762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato        public void animateExpand();
914762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato        public void animateCollapse();
9260ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler        public void setSystemUiVisibility(int vis);
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();
987f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka        public void cancelPreloadRecentApps();
99328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler        public void setNavigationIconHints(int hints);
1000cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
1010cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
1020cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public CommandQueue(Callbacks callbacks, StatusBarIconList list) {
1030cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        mCallbacks = callbacks;
1040cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        mList = list;
1050cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
1060cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
1070cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public void setIcon(int index, StatusBarIcon icon) {
1080cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        synchronized (mList) {
1090cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            int what = MSG_ICON | index;
1100cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            mHandler.removeMessages(what);
1110cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            mHandler.obtainMessage(what, OP_SET_ICON, 0, icon.clone()).sendToTarget();
1120cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        }
1130cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
1140cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
1150cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public void removeIcon(int index) {
1160cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        synchronized (mList) {
1170cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            int what = MSG_ICON | index;
1180cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            mHandler.removeMessages(what);
1190cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            mHandler.obtainMessage(what, OP_REMOVE_ICON, 0, null).sendToTarget();
1200cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        }
1210cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
1220cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
123a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    public void addNotification(IBinder key, StatusBarNotification notification) {
124a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        synchronized (mList) {
125a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            NotificationQueueEntry ne = new NotificationQueueEntry();
126a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            ne.key = key;
127a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            ne.notification = notification;
128a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            mHandler.obtainMessage(MSG_ADD_NOTIFICATION, 0, 0, ne).sendToTarget();
129a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        }
130a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    }
131a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato
132a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    public void updateNotification(IBinder key, StatusBarNotification notification) {
133a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        synchronized (mList) {
134a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            NotificationQueueEntry ne = new NotificationQueueEntry();
135a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            ne.key = key;
136a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            ne.notification = notification;
137a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            mHandler.obtainMessage(MSG_UPDATE_NOTIFICATION, 0, 0, ne).sendToTarget();
138a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        }
139a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    }
140a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato
141a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    public void removeNotification(IBinder key) {
142a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        synchronized (mList) {
143a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato            mHandler.obtainMessage(MSG_REMOVE_NOTIFICATION, 0, 0, key).sendToTarget();
144a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato        }
145a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato    }
146a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato
147f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato    public void disable(int state) {
148f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato        synchronized (mList) {
149f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato            mHandler.removeMessages(MSG_DISABLE);
150f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato            mHandler.obtainMessage(MSG_DISABLE, state, 0, null).sendToTarget();
151f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato        }
152f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato    }
153f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato
1544762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato    public void animateExpand() {
1554762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato        synchronized (mList) {
1564762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato            mHandler.removeMessages(MSG_SET_VISIBILITY);
1574762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato            mHandler.obtainMessage(MSG_SET_VISIBILITY, OP_EXPAND, 0, null).sendToTarget();
1584762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato        }
1594762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato    }
1604762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato
1614762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato    public void animateCollapse() {
1624762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato        synchronized (mList) {
1634762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato            mHandler.removeMessages(MSG_SET_VISIBILITY);
1644762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato            mHandler.obtainMessage(MSG_SET_VISIBILITY, OP_COLLAPSE, 0, null).sendToTarget();
1654762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato        }
1664762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato    }
1674762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato
16860ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler    public void setSystemUiVisibility(int vis) {
1699305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato        synchronized (mList) {
17060ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler            mHandler.removeMessages(MSG_SET_SYSTEMUI_VISIBILITY);
17160ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler            mHandler.obtainMessage(MSG_SET_SYSTEMUI_VISIBILITY, vis, 0, null).sendToTarget();
1729305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato        }
1739305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato    }
1749305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato
1757d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn    public void topAppWindowChanged(boolean menuVisible) {
176e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler        synchronized (mList) {
1777d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn            mHandler.removeMessages(MSG_TOP_APP_WINDOW_CHANGED);
1787d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn            mHandler.obtainMessage(MSG_TOP_APP_WINDOW_CHANGED, menuVisible ? 1 : 0, 0,
1797d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn                    null).sendToTarget();
180e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler        }
181e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler    }
182e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler
183857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato    public void setImeWindowStatus(IBinder token, int vis, int backDisposition) {
18406487a58be22b100daf3f950b9a1d25c3ea42aa2satok        synchronized (mList) {
18506487a58be22b100daf3f950b9a1d25c3ea42aa2satok            mHandler.removeMessages(MSG_SHOW_IME_BUTTON);
186857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato            mHandler.obtainMessage(MSG_SHOW_IME_BUTTON, vis, backDisposition, token)
187857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato                    .sendToTarget();
18806487a58be22b100daf3f950b9a1d25c3ea42aa2satok        }
18906487a58be22b100daf3f950b9a1d25c3ea42aa2satok    }
19006487a58be22b100daf3f950b9a1d25c3ea42aa2satok
1912992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown    public void setHardKeyboardStatus(boolean available, boolean enabled) {
1922992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown        synchronized (mList) {
1932992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown            mHandler.removeMessages(MSG_SET_HARD_KEYBOARD_STATUS);
1942992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown            mHandler.obtainMessage(MSG_SET_HARD_KEYBOARD_STATUS,
1952992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown                    available ? 1 : 0, enabled ? 1 : 0).sendToTarget();
1962992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown        }
1972992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown    }
1982992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown
1993b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka    public void toggleRecentApps() {
2003b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka        synchronized (mList) {
2013b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka            mHandler.removeMessages(MSG_TOGGLE_RECENT_APPS);
2023b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka            mHandler.obtainMessage(MSG_TOGGLE_RECENT_APPS, 0, 0, null).sendToTarget();
2033b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka        }
2043b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka    }
2053b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka
2067f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka    public void preloadRecentApps() {
2077f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka        synchronized (mList) {
2087f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka            mHandler.removeMessages(MSG_PRELOAD_RECENT_APPS);
2097f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka            mHandler.obtainMessage(MSG_PRELOAD_RECENT_APPS, 0, 0, null).sendToTarget();
2107f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka        }
2117f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka    }
2127f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka
2137f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka    public void cancelPreloadRecentApps() {
2147f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka        synchronized (mList) {
2157f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka            mHandler.removeMessages(MSG_CANCEL_PRELOAD_RECENT_APPS);
2167f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka            mHandler.obtainMessage(MSG_CANCEL_PRELOAD_RECENT_APPS, 0, 0, null).sendToTarget();
2177f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka        }
2187f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka    }
2197f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka
220328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler    public void setNavigationIconHints(int hints) {
221328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler        synchronized (mList) {
222328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler            mHandler.removeMessages(MSG_SET_NAVIGATION_ICON_HINTS);
223328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler            mHandler.obtainMessage(MSG_SET_NAVIGATION_ICON_HINTS, hints, 0, null).sendToTarget();
224328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler        }
225328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler    }
226328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler
2270cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    private final class H extends Handler {
2280cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        public void handleMessage(Message msg) {
229f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato            final int what = msg.what & MSG_MASK;
23066d7d01ed91968f4ed2e2669fd306aa2af61cd16Joe Onorato            switch (what) {
2310cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                case MSG_ICON: {
232f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato                    final int index = msg.what & INDEX_MASK;
233f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato                    final int viewIndex = mList.getViewIndex(index);
2340cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                    switch (msg.arg1) {
2350cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                        case OP_SET_ICON: {
2360cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            StatusBarIcon icon = (StatusBarIcon)msg.obj;
2370cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            StatusBarIcon old = mList.getIcon(index);
2380cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            if (old == null) {
2390cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                                mList.setIcon(index, icon);
2400cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                                mCallbacks.addIcon(mList.getSlot(index), index, viewIndex, icon);
2410cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            } else {
2420cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                                mList.setIcon(index, icon);
2430cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                                mCallbacks.updateIcon(mList.getSlot(index), index, viewIndex,
2440cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                                        old, icon);
2450cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            }
2460cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            break;
2470cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                        }
2480cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                        case OP_REMOVE_ICON:
249795f2840b4a70bf188c2f24c8c06f73a492b338cJoe Onorato                            if (mList.getIcon(index) != null) {
250795f2840b4a70bf188c2f24c8c06f73a492b338cJoe Onorato                                mList.removeIcon(index);
251795f2840b4a70bf188c2f24c8c06f73a492b338cJoe Onorato                                mCallbacks.removeIcon(mList.getSlot(index), index, viewIndex);
252795f2840b4a70bf188c2f24c8c06f73a492b338cJoe Onorato                            }
2530cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                            break;
2540cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                    }
2550cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato                    break;
256f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato                }
257a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                case MSG_ADD_NOTIFICATION: {
258a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    final NotificationQueueEntry ne = (NotificationQueueEntry)msg.obj;
259a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    mCallbacks.addNotification(ne.key, ne.notification);
260a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    break;
261a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                }
262a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                case MSG_UPDATE_NOTIFICATION: {
263a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    final NotificationQueueEntry ne = (NotificationQueueEntry)msg.obj;
264a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    mCallbacks.updateNotification(ne.key, ne.notification);
265a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    break;
266a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                }
267a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                case MSG_REMOVE_NOTIFICATION: {
268a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    mCallbacks.removeNotification((IBinder)msg.obj);
269a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                    break;
270a0c56fe93925d20d9c0b830b9664699ce557e78cJoe Onorato                }
271f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato                case MSG_DISABLE:
272f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato                    mCallbacks.disable(msg.arg1);
273f3f0e053f0cc66249a11639eb67d0cdc2da26dedJoe Onorato                    break;
2744762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato                case MSG_SET_VISIBILITY:
2754762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato                    if (msg.arg1 == OP_EXPAND) {
2764762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato                        mCallbacks.animateExpand();
2774762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato                    } else {
2784762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato                        mCallbacks.animateCollapse();
2794762c2d75a55e0854bbff2f996748116d4ab1a37Joe Onorato                    }
2809305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato                    break;
28160ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler                case MSG_SET_SYSTEMUI_VISIBILITY:
28260ee25643e0a7b8841063a4e97b0f18c51807e91Daniel Sandler                    mCallbacks.setSystemUiVisibility(msg.arg1);
2839305647eb61bb60a1f42481a0c0d208dc9bbe965Joe Onorato                    break;
2847d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn                case MSG_TOP_APP_WINDOW_CHANGED:
2857d04932ef5c001769ccef244f551b75773f1666bDianne Hackborn                    mCallbacks.topAppWindowChanged(msg.arg1 != 0);
286e02d808abf370965c3c4e4d38af11bc69110fde2Daniel Sandler                    break;
28706487a58be22b100daf3f950b9a1d25c3ea42aa2satok                case MSG_SHOW_IME_BUTTON:
288857fd9b8562c29913e03ed29288bd1802d37dc60Joe Onorato                    mCallbacks.setImeWindowStatus((IBinder)msg.obj, msg.arg1, msg.arg2);
28906487a58be22b100daf3f950b9a1d25c3ea42aa2satok                    break;
2902992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown                case MSG_SET_HARD_KEYBOARD_STATUS:
2912992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown                    mCallbacks.setHardKeyboardStatus(msg.arg1 != 0, msg.arg2 != 0);
2922992ea782fa61780d8e0de7a36a2a84622f8694bJeff Brown                    break;
2933b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka                case MSG_TOGGLE_RECENT_APPS:
2943b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka                    mCallbacks.toggleRecentApps();
2953b1fc47d004f6b29af8f40d181baa3460b1e3b15Michael Jurka                    break;
2967f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka                case MSG_PRELOAD_RECENT_APPS:
2977f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka                    mCallbacks.preloadRecentApps();
2987f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka                    break;
2997f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka                case MSG_CANCEL_PRELOAD_RECENT_APPS:
3007f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka                    mCallbacks.cancelPreloadRecentApps();
3017f2668c8469934ce83a5647977f6e74ab782cf07Michael Jurka                    break;
302328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler                case MSG_SET_NAVIGATION_ICON_HINTS:
303328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler                    mCallbacks.setNavigationIconHints(msg.arg1);
304328310c6fac6066d338926bb43d359862cae36d2Daniel Sandler                    break;
3050cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            }
3060cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        }
3070cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
3080cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato}
3090cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
310