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

Commit 42b82a4d authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Remove calls that iterate on MessageQueue

Test: enable flag and then NotificationManagerServiceTest
Bug: 311051285
Flag: aconfig com.android.server.notification.notification_reduce_messagequeue_usage
Change-Id: Idf8e050fa6fc5703743dc1c920c973e1e04b9277
parent 24859057
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -9573,12 +9573,16 @@ public class NotificationManagerService extends SystemService {
    }
    private void scheduleListenerHintsChanged(int state) {
        if (!Flags.notificationReduceMessagequeueUsage()) {
            mHandler.removeMessages(MESSAGE_LISTENER_HINTS_CHANGED);
        }
        mHandler.obtainMessage(MESSAGE_LISTENER_HINTS_CHANGED, state, 0).sendToTarget();
    }
    private void scheduleInterruptionFilterChanged(int listenerInterruptionFilter) {
        if (!Flags.notificationReduceMessagequeueUsage()) {
            mHandler.removeMessages(MESSAGE_LISTENER_NOTIFICATION_FILTER_CHANGED);
        }
        mHandler.obtainMessage(
                MESSAGE_LISTENER_NOTIFICATION_FILTER_CHANGED,
                listenerInterruptionFilter,
@@ -9658,17 +9662,26 @@ public class NotificationManagerService extends SystemService {
        }
        protected void scheduleSendRankingUpdate() {
            if (Flags.notificationReduceMessagequeueUsage()) {
                Message m = Message.obtain(this, MESSAGE_SEND_RANKING_UPDATE);
                sendMessage(m);
            } else {
                if (!hasMessages(MESSAGE_SEND_RANKING_UPDATE)) {
                    Message m = Message.obtain(this, MESSAGE_SEND_RANKING_UPDATE);
                    sendMessage(m);
                }
            }
        }
        protected void scheduleCancelNotification(CancelNotificationRunnable cancelRunnable) {
            if (Flags.notificationReduceMessagequeueUsage()) {
                sendMessage(Message.obtain(this, cancelRunnable));
            } else {
                if (!hasCallbacks(cancelRunnable)) {
                    sendMessage(Message.obtain(this, cancelRunnable));
                }
            }
        }
        protected void scheduleOnPackageChanged(boolean removingPackage, int changeUserId,
                String[] pkgList, int[] uidList) {
@@ -9700,7 +9713,9 @@ public class NotificationManagerService extends SystemService {
        }
        public void requestSort() {
            if (!Flags.notificationReduceMessagequeueUsage()) {
                removeMessages(MESSAGE_RANKING_SORT);
            }
            Message msg = Message.obtain();
            msg.what = MESSAGE_RANKING_SORT;
            sendMessage(msg);
+7 −0
Original line number Diff line number Diff line
@@ -50,3 +50,10 @@ flag {
  # Referenced in WM where WM starts before DeviceConfig
  is_fixed_read_only: true
}

flag {
  name: "notification_reduce_messagequeue_usage"
  namespace: "systemui"
  description: "When this flag is on, NMS will no longer call removeMessage() and hasCallbacks() on Handler"
  bug: "311051285"
}
 No newline at end of file