Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e58b3c6 authored by Christoph Studer's avatar Christoph Studer Committed by Android (Google) Code Review
Browse files

Merge "Remove notification APIs from StatusBar service"

parents 3dd5118b e71fefcc
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -24,9 +24,6 @@ oneway interface IStatusBar
{
    void setIcon(int index, in StatusBarIcon icon);
    void removeIcon(int index);
    void addNotification(in StatusBarNotification notification);
    void updateNotification(in StatusBarNotification notification);
    void removeNotification(String key);
    void disable(int state);
    void animateExpandNotificationsPanel();
    void animateExpandSettingsPanel();
+1 −2
Original line number Diff line number Diff line
@@ -39,8 +39,7 @@ interface IStatusBarService
    // ---- Methods below are for use by the status bar policy services ----
    // You need the STATUS_BAR_SERVICE permission
    void registerStatusBar(IStatusBar callbacks, out StatusBarIconList iconList,
            out List<StatusBarNotification> notifications, out int[] switches,
            out List<IBinder> binders);
            out int[] switches, out List<IBinder> binders);
    void onPanelRevealed();
    void onPanelHidden();
    void onNotificationClick(String key);
+25 −60
Original line number Diff line number Diff line
@@ -94,7 +94,6 @@ public abstract class BaseStatusBar extends SystemUI implements
    public static final String TAG = "StatusBar";
    public static final boolean DEBUG = false;
    public static final boolean MULTIUSER_DEBUG = false;
    private static final boolean USE_NOTIFICATION_LISTENER = true;

    protected static final int MSG_SHOW_RECENT_APPS = 1019;
    protected static final int MSG_HIDE_RECENT_APPS = 1020;
@@ -298,7 +297,7 @@ public abstract class BaseStatusBar extends SystemUI implements
                @Override
                public void run() {
                    for (StatusBarNotification sbn : notifications) {
                        addNotificationInternal(sbn, currentRanking);
                        addNotification(sbn, currentRanking);
                    }
                }
            });
@@ -325,16 +324,16 @@ public abstract class BaseStatusBar extends SystemUI implements
                        // wasn't a group child, remove the old instance.
                        // Otherwise just update the ranking.
                        if (isUpdate) {
                            removeNotificationInternal(sbn.getKey(), rankingMap);
                            removeNotification(sbn.getKey(), rankingMap);
                        } else {
                            updateRankingInternal(rankingMap);
                            updateNotificationRanking(rankingMap);
                        }
                        return;
                    }
                    if (isUpdate) {
                        updateNotificationInternal(sbn, rankingMap);
                        updateNotification(sbn, rankingMap);
                    } else {
                        addNotificationInternal(sbn, rankingMap);
                        addNotification(sbn, rankingMap);
                    }
                }
            });
@@ -347,7 +346,7 @@ public abstract class BaseStatusBar extends SystemUI implements
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    removeNotificationInternal(sbn.getKey(), rankingMap);
                    removeNotification(sbn.getKey(), rankingMap);
                }
            });
        }
@@ -358,7 +357,7 @@ public abstract class BaseStatusBar extends SystemUI implements
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    updateRankingInternal(rankingMap);
                    updateNotificationRanking(rankingMap);
                }
            });
        }
@@ -414,14 +413,12 @@ public abstract class BaseStatusBar extends SystemUI implements

        // Connect in to the status bar manager service
        StatusBarIconList iconList = new StatusBarIconList();
        ArrayList<StatusBarNotification> notifications = new ArrayList<StatusBarNotification>();
        mCommandQueue = new CommandQueue(this, iconList);

        int[] switches = new int[8];
        ArrayList<IBinder> binders = new ArrayList<IBinder>();
        try {
            mBarService.registerStatusBar(mCommandQueue, iconList, notifications,
                    switches, binders);
            mBarService.registerStatusBar(mCommandQueue, iconList, switches, binders);
        } catch (RemoteException ex) {
            // If the system process isn't there we're doomed anyway.
        }
@@ -447,7 +444,6 @@ public abstract class BaseStatusBar extends SystemUI implements
        }

        // Set up the initial notification state.
        if (USE_NOTIFICATION_LISTENER) {
        try {
            mNotificationListener.registerAsSystemService(
                    new ComponentName(mContext.getPackageName(), getClass().getCanonicalName()),
@@ -455,12 +451,6 @@ public abstract class BaseStatusBar extends SystemUI implements
        } catch (RemoteException e) {
            Log.e(TAG, "Unable to register notification listener", e);
        }
        } else {
            N = notifications.size();
            for (int i=0; i<N; i++) {
                addNotification(notifications.get(i));
            }
        }


        if (DEBUG) {
@@ -1194,7 +1184,7 @@ public abstract class BaseStatusBar extends SystemUI implements
     * WARNING: this will call back into us.  Don't hold any locks.
     */
    void handleNotificationError(StatusBarNotification n, String message) {
        removeNotification(n.getKey());
        removeNotification(n.getKey(), null);
        try {
            mBarService.onNotificationError(n.getPackageName(), n.getTag(), n.getId(), n.getUid(),
                    n.getInitialPid(), message, n.getUserId());
@@ -1330,34 +1320,11 @@ public abstract class BaseStatusBar extends SystemUI implements
    protected abstract void updateExpandedViewPos(int expandedPosition);
    protected abstract boolean shouldDisableNavbarGestures();

    @Override
    public void addNotification(StatusBarNotification notification) {
        if (!USE_NOTIFICATION_LISTENER) {
            addNotificationInternal(notification, null);
        }
    }

    public abstract void addNotificationInternal(StatusBarNotification notification,
    public abstract void addNotification(StatusBarNotification notification,
            RankingMap ranking);

    protected abstract void updateRankingInternal(RankingMap ranking);

    @Override
    public void removeNotification(String key) {
        if (!USE_NOTIFICATION_LISTENER) {
            removeNotificationInternal(key, null);
        }
    }

    public abstract void removeNotificationInternal(String key, RankingMap ranking);

    public void updateNotification(StatusBarNotification notification) {
        if (!USE_NOTIFICATION_LISTENER) {
            updateNotificationInternal(notification, null);
        }
    }

    public void updateNotificationInternal(StatusBarNotification notification, RankingMap ranking) {
    protected abstract void updateNotificationRanking(RankingMap ranking);
    public abstract void removeNotification(String key, RankingMap ranking);
    public void updateNotification(StatusBarNotification notification, RankingMap ranking) {
        if (DEBUG) Log.d(TAG, "updateNotification(" + notification + ")");

        final String key = notification.getKey();
@@ -1474,7 +1441,7 @@ public abstract class BaseStatusBar extends SystemUI implements
                } else {
                    if (shouldInterrupt && alertAgain) {
                        removeNotificationViews(key, ranking);
                        addNotificationInternal(notification, ranking);  //this will pop the headsup
                        addNotification(notification, ranking);  //this will pop the headsup
                    } else {
                        updateNotificationViews(oldEntry, notification);
                    }
@@ -1514,7 +1481,7 @@ public abstract class BaseStatusBar extends SystemUI implements
                if (shouldInterrupt && alertAgain) {
                    if (DEBUG) Log.d(TAG, "reposting to invoke heads up for key: " + key);
                    removeNotificationViews(key, ranking);
                    addNotificationInternal(notification, ranking);  //this will pop the headsup
                    addNotification(notification, ranking);  //this will pop the headsup
                } else {
                    if (DEBUG) Log.d(TAG, "rebuilding update in place for key: " + key);
                    removeNotificationViews(key, ranking);
@@ -1672,7 +1639,6 @@ public abstract class BaseStatusBar extends SystemUI implements
            mWindowManager.removeViewImmediate(mSearchPanelView);
        }
        mContext.unregisterReceiver(mBroadcastReceiver);
        if (USE_NOTIFICATION_LISTENER) {
        try {
            mNotificationListener.unregisterAsSystemService();
        } catch (RemoteException e) {
@@ -1680,4 +1646,3 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
    }
}
}
+14 −52
Original line number Diff line number Diff line
@@ -41,23 +41,20 @@ public class CommandQueue extends IStatusBar.Stub {
    private static final int OP_REMOVE_ICON = 2;

    private static final int MSG_ICON                       = 1 << MSG_SHIFT;
    private static final int MSG_ADD_NOTIFICATION           = 2 << MSG_SHIFT;
    private static final int MSG_UPDATE_NOTIFICATION        = 3 << MSG_SHIFT;
    private static final int MSG_REMOVE_NOTIFICATION        = 4 << MSG_SHIFT;
    private static final int MSG_DISABLE                    = 5 << MSG_SHIFT;
    private static final int MSG_EXPAND_NOTIFICATIONS       = 6 << MSG_SHIFT;
    private static final int MSG_COLLAPSE_PANELS            = 7 << MSG_SHIFT;
    private static final int MSG_EXPAND_SETTINGS            = 8 << MSG_SHIFT;
    private static final int MSG_SET_SYSTEMUI_VISIBILITY    = 9 << MSG_SHIFT;
    private static final int MSG_TOP_APP_WINDOW_CHANGED     = 10 << MSG_SHIFT;
    private static final int MSG_SHOW_IME_BUTTON            = 11 << MSG_SHIFT;
    private static final int MSG_SET_HARD_KEYBOARD_STATUS   = 12 << MSG_SHIFT;
    private static final int MSG_TOGGLE_RECENT_APPS         = 13 << MSG_SHIFT;
    private static final int MSG_PRELOAD_RECENT_APPS        = 14 << MSG_SHIFT;
    private static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 15 << MSG_SHIFT;
    private static final int MSG_SET_WINDOW_STATE           = 16 << MSG_SHIFT;
    private static final int MSG_SHOW_RECENT_APPS           = 17 << MSG_SHIFT;
    private static final int MSG_HIDE_RECENT_APPS           = 18 << MSG_SHIFT;
    private static final int MSG_DISABLE                    = 2 << MSG_SHIFT;
    private static final int MSG_EXPAND_NOTIFICATIONS       = 3 << MSG_SHIFT;
    private static final int MSG_COLLAPSE_PANELS            = 4 << MSG_SHIFT;
    private static final int MSG_EXPAND_SETTINGS            = 5 << MSG_SHIFT;
    private static final int MSG_SET_SYSTEMUI_VISIBILITY    = 6 << MSG_SHIFT;
    private static final int MSG_TOP_APP_WINDOW_CHANGED     = 7 << MSG_SHIFT;
    private static final int MSG_SHOW_IME_BUTTON            = 8 << MSG_SHIFT;
    private static final int MSG_SET_HARD_KEYBOARD_STATUS   = 9 << MSG_SHIFT;
    private static final int MSG_TOGGLE_RECENT_APPS         = 10 << MSG_SHIFT;
    private static final int MSG_PRELOAD_RECENT_APPS        = 11 << MSG_SHIFT;
    private static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 12 << MSG_SHIFT;
    private static final int MSG_SET_WINDOW_STATE           = 13 << MSG_SHIFT;
    private static final int MSG_SHOW_RECENT_APPS           = 14 << MSG_SHIFT;
    private static final int MSG_HIDE_RECENT_APPS           = 15 << MSG_SHIFT;

    public static final int FLAG_EXCLUDE_NONE = 0;
    public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -80,9 +77,6 @@ public class CommandQueue extends IStatusBar.Stub {
        public void updateIcon(String slot, int index, int viewIndex,
                StatusBarIcon old, StatusBarIcon icon);
        public void removeIcon(String slot, int index, int viewIndex);
        public void addNotification(StatusBarNotification notification);
        public void updateNotification(StatusBarNotification notification);
        public void removeNotification(String key);
        public void disable(int state);
        public void animateExpandNotificationsPanel();
        public void animateCollapsePanels(int flags);
@@ -123,26 +117,6 @@ public class CommandQueue extends IStatusBar.Stub {
        }
    }

    @Override
    public void addNotification(StatusBarNotification notification) {
        synchronized (mList) {
            mHandler.obtainMessage(MSG_ADD_NOTIFICATION, 0, 0, notification).sendToTarget();
        }
    }

    @Override
    public void updateNotification(StatusBarNotification notification) {
        synchronized (mList) {
            mHandler.obtainMessage(MSG_UPDATE_NOTIFICATION, 0, 0, notification).sendToTarget();
        }
    }

    public void removeNotification(String key) {
        synchronized (mList) {
            mHandler.obtainMessage(MSG_REMOVE_NOTIFICATION, 0, 0, key).sendToTarget();
        }
    }

    public void disable(int state) {
        synchronized (mList) {
            mHandler.removeMessages(MSG_DISABLE);
@@ -279,18 +253,6 @@ public class CommandQueue extends IStatusBar.Stub {
                    }
                    break;
                }
                case MSG_ADD_NOTIFICATION: {
                    mCallbacks.addNotification((StatusBarNotification) msg.obj);
                    break;
                }
                case MSG_UPDATE_NOTIFICATION: {
                    mCallbacks.updateNotification((StatusBarNotification) msg.obj);
                    break;
                }
                case MSG_REMOVE_NOTIFICATION: {
                    mCallbacks.removeNotification((String) msg.obj);
                    break;
                }
                case MSG_DISABLE:
                    mCallbacks.disable(msg.arg1);
                    break;
+2 −2
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ public class InterceptedNotifications {
    private void updateSyntheticNotification() {
        if (mIntercepted.isEmpty()) {
            if (mSynKey != null) {
                mBar.removeNotificationInternal(mSynKey, null);
                mBar.removeNotification(mSynKey, null);
                mSynKey = null;
            }
            return;
@@ -128,7 +128,7 @@ public class InterceptedNotifications {
            mSynKey = sbn.getKey();
            mBar.displayNotification(sbn, null);
        } else {
           mBar.updateNotificationInternal(sbn, null);
           mBar.updateNotification(sbn, null);
        }
        final NotificationData.Entry entry = mBar.mNotificationData.findByKey(mSynKey);
        entry.row.setOnClickListener(mSynClickListener);
Loading