Merge "Revert "Revert "Add "incrementEventCountBy" function to Onboardi..."" into tm-dev am: 223bfe0908 am: 5b39a7db99

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/18570019

Change-Id: I7562458f5f5e47d13bb016f0a4fe6e9034c3e77e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/launcher3/util/OnboardingPrefs.java b/src/com/android/launcher3/util/OnboardingPrefs.java
index c1e4fa8..64aeceb 100644
--- a/src/com/android/launcher3/util/OnboardingPrefs.java
+++ b/src/com/android/launcher3/util/OnboardingPrefs.java
@@ -140,4 +140,19 @@
         mSharedPrefs.edit().putInt(eventKey, count).apply();
         return hasReachedMaxCount(count, eventKey);
     }
+
+    /**
+     * Add "incCountBy" to the given event count, if we haven't already reached the max count.
+     *
+     * @return Whether we have now reached the max count.
+     */
+    public boolean incrementEventCountBy(int incCountBy, @EventCountKey String eventKey) {
+        int count = getCount(eventKey);
+        if (hasReachedMaxCount(count, eventKey)) {
+            return true;
+        }
+        count += incCountBy;
+        mSharedPrefs.edit().putInt(eventKey, count).apply();
+        return hasReachedMaxCount(count, eventKey);
+    }
 }