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

Commit 7983f2b7 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Make tracking notification ttls more performant

By only using 1 alarm instead of 1 per notification.

Also, enabled NMSTest to be parameterized with flags. This required some
more mocking and cleanup steps to keep memory usage under control when
running so many more tests.

Test: NotificationManagerServiceTest
Test: TimeToLiveHelperTest
Bug: 331967355
Flag: com.android.server.notification.all_notifs_need_ttl DEV
Change-Id: If6cff0fa4667b48def17c7ec1b4aa78340d335b7
parent 42650607
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -581,6 +581,7 @@

    <protected-broadcast android:name="android.app.action.KEYGUARD_PRIVATE_NOTIFICATIONS_CHANGED" />
    <protected-broadcast android:name="NotificationManagerService.TIMEOUT" />
    <protected-broadcast android:name="com.android.server.notification.TimeToLiveHelper" />
    <protected-broadcast android:name="NotificationHistoryDatabase.CLEANUP" />
    <protected-broadcast android:name="ScheduleConditionProvider.EVALUATE" />
    <protected-broadcast android:name="EventConditionProvider.EVALUATE" />
+2 −0
Original line number Diff line number Diff line
@@ -25,4 +25,6 @@ import android.annotation.Nullable;
interface NotificationManagerPrivate {
    @Nullable
    NotificationRecord getNotificationByKey(String key);

    void timeoutNotification(String key);
}
+208 −114

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ import dalvik.annotation.optimization.NeverCompile;

import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -600,8 +601,7 @@ public final class NotificationRecord {
        pw.println(prefix + "headsUpContentView="
                + formatRemoteViews(notification.headsUpContentView));
        pw.println(prefix + String.format("color=0x%08x", notification.color));
        pw.println(prefix + "timeout="
                + TimeUtils.formatForLogging(notification.getTimeoutAfter()));
        pw.println(prefix + "timeout=" + Duration.ofMillis(notification.getTimeoutAfter()));
        if (notification.actions != null && notification.actions.length > 0) {
            pw.println(prefix + "actions={");
            final int N = notification.actions.length;
+7 −0
Original line number Diff line number Diff line
@@ -287,4 +287,11 @@ public class ShortcutHelper {
            }
        }
    }

    void destroy() {
        if (mLauncherAppsCallbackRegistered) {
            mLauncherAppsService.unregisterCallback(mLauncherAppsCallback);
            mLauncherAppsCallbackRegistered = false;
        }
    }
}
Loading