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

Commit 05e28849 authored by Christoph Studer's avatar Christoph Studer
Browse files

NoMan: Allow disabling SQLiteLog.

Bug: 15279504
Change-Id: I561391a312f88a7d5e11b180984f18bb1d3dcda0
parent c22dbb69
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -46,12 +46,14 @@ import java.util.Map;
 * {@hide}
 */
public class NotificationUsageStats {
    private static final boolean ENABLE_SQLITE_LOG = true;

    // Guarded by synchronized(this).
    private final Map<String, AggregatedStats> mStats = new HashMap<String, AggregatedStats>();
    private final SQLiteLog mSQLiteLog;

    public NotificationUsageStats(Context context) {
        mSQLiteLog = new SQLiteLog(context);
        mSQLiteLog = ENABLE_SQLITE_LOG ? new SQLiteLog(context) : null;
    }

    /**
@@ -63,8 +65,10 @@ public class NotificationUsageStats {
        for (AggregatedStats stats : getAggregatedStatsLocked(notification)) {
            stats.numPostedByApp++;
        }
        if (ENABLE_SQLITE_LOG) {
            mSQLiteLog.logPosted(notification);
        }
    }

    /**
     * Called when a notification has been updated.
@@ -85,8 +89,10 @@ public class NotificationUsageStats {
            stats.numRemovedByApp++;
            stats.collect(notification.stats);
        }
        if (ENABLE_SQLITE_LOG) {
            mSQLiteLog.logRemoved(notification);
        }
    }

    /**
     * Called when the user dismissed the notification via the UI.
@@ -97,8 +103,10 @@ public class NotificationUsageStats {
            stats.numDismissedByUser++;
            stats.collect(notification.stats);
        }
        if (ENABLE_SQLITE_LOG) {
            mSQLiteLog.logDismissed(notification);
        }
    }

    /**
     * Called when the user clicked the notification in the UI.
@@ -108,8 +116,10 @@ public class NotificationUsageStats {
        for (AggregatedStats stats : getAggregatedStatsLocked(notification)) {
            stats.numClickedByUser++;
        }
        if (ENABLE_SQLITE_LOG) {
            mSQLiteLog.logClicked(notification);
        }
    }

    /**
     * Called when the notification is canceled because the user clicked it.
@@ -164,8 +174,10 @@ public class NotificationUsageStats {
        for (AggregatedStats as : mStats.values()) {
            as.dump(pw, indent);
        }
        if (ENABLE_SQLITE_LOG) {
            mSQLiteLog.dump(pw, indent);
        }
    }

    /**
     * Aggregated notification stats.