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

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

Merge "NoMan: Add flag to turn off aggregated in-mem stats" into lmp-dev

parents a802e26d 856b2b81
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -46,8 +46,13 @@ import java.util.Map;
 * {@hide}
 */
public class NotificationUsageStats {
    // WARNING: Aggregated stats can grow unboundedly with pkg+id+tag.
    // Don't enable on production builds.
    private static final boolean ENABLE_AGGREGATED_IN_MEMORY_STATS = true;
    private static final boolean ENABLE_SQLITE_LOG = true;

    private static final AggregatedStats[] EMPTY_AGGREGATED_STATS = new AggregatedStats[0];

    // Guarded by synchronized(this).
    private final Map<String, AggregatedStats> mStats = new HashMap<String, AggregatedStats>();
    private final SQLiteLog mSQLiteLog;
@@ -147,6 +152,10 @@ public class NotificationUsageStats {

    // Locked by this.
    private AggregatedStats[] getAggregatedStatsLocked(NotificationRecord record) {
        if (!ENABLE_AGGREGATED_IN_MEMORY_STATS) {
            return EMPTY_AGGREGATED_STATS;
        }

        StatusBarNotification n = record.sbn;

        String user = String.valueOf(n.getUserId());
@@ -171,10 +180,13 @@ public class NotificationUsageStats {
    }

    public synchronized void dump(PrintWriter pw, String indent, DumpFilter filter) {
        if (ENABLE_AGGREGATED_IN_MEMORY_STATS) {
            for (AggregatedStats as : mStats.values()) {
            if (filter != null && !filter.matches(as.key)) continue;
                if (filter != null && !filter.matches(as.key))
                    continue;
                as.dump(pw, indent);
            }
        }
        if (ENABLE_SQLITE_LOG) {
            mSQLiteLog.dump(pw, indent, filter);
        }