[WifiScoreCard] Enable rssi histograms

Enable rssi histograms for selected event types. Use a bucket size
of 1 for values between -100 and -20.

Bug: 136675430
Test: atest WifiScoreCardTest
Change-Id: Ic7ee5b2a6c4d100bfa35c7ff544f5f13c2aa1bd6
diff --git a/service/java/com/android/server/wifi/WifiScoreCard.java b/service/java/com/android/server/wifi/WifiScoreCard.java
index fa6de23..cc5f128 100644
--- a/service/java/com/android/server/wifi/WifiScoreCard.java
+++ b/service/java/com/android/server/wifi/WifiScoreCard.java
@@ -72,7 +72,7 @@
     private static final boolean DBG = false;
 
     @VisibleForTesting
-    boolean mPersistentHistograms = false; // not ready yet
+    boolean mPersistentHistograms = true;
 
     private static final int TARGET_IN_MEMORY_ENTRIES = 50;
 
@@ -81,10 +81,15 @@
     private MemoryStore mMemoryStore;
 
     @VisibleForTesting
-    static final int[] RSSI_BUCKETS =
-            {-99, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73,
-                    -72, -71, -70, -66, -55};
+    static final int[] RSSI_BUCKETS = intsInRange(-100, -20);
 
+    private static int[] intsInRange(int min, int max) {
+        int[] a = new int[max - min + 1];
+        for (int i = 0; i < a.length; i++) {
+            a[i] = min + i;
+        }
+        return a;
+    }
 
     /** Our view of the memory store */
     public interface MemoryStore {
@@ -773,8 +778,16 @@
         PerSignal(Event event, int frequency) {
             this.event = event;
             this.frequency = frequency;
-            // TODO(b/136675430) - histograms not needed for all events?
-            this.rssi = new PerUnivariateStatistic(RSSI_BUCKETS);
+            switch (event) {
+                case SIGNAL_POLL:
+                case IP_CONFIGURATION_SUCCESS:
+                case IP_REACHABILITY_LOST:
+                    this.rssi = new PerUnivariateStatistic(RSSI_BUCKETS);
+                    break;
+                default:
+                    this.rssi = new PerUnivariateStatistic();
+                    break;
+            }
             this.linkspeed = new PerUnivariateStatistic();
             switch (event) {
                 case FIRST_POLL_AFTER_CONNECTION: