Pull out library needed for Notification CTS test.
Bug: 152031499
Test: atest NotificationManagerServiceTest
Change-Id: I6292482b3650709149ff06249ba4a3704289ee46
diff --git a/services/core/java/com/android/server/notification/NotificationRecordLogger.java b/services/core/java/com/android/server/notification/NotificationRecordLogger.java
index 6c833f9..eba5730 100644
--- a/services/core/java/com/android/server/notification/NotificationRecordLogger.java
+++ b/services/core/java/com/android/server/notification/NotificationRecordLogger.java
@@ -359,43 +359,24 @@
* @return Small hash of the notification ID, and tag (if present).
*/
int getNotificationIdHash() {
- return smallHash(Objects.hashCode(r.getSbn().getTag()) ^ r.getSbn().getId());
+ return SmallHash.hash(Objects.hashCode(r.getSbn().getTag()) ^ r.getSbn().getId());
}
/**
* @return Small hash of the channel ID, if present, or 0 otherwise.
*/
int getChannelIdHash() {
- return smallHash(r.getSbn().getNotification().getChannelId());
+ return SmallHash.hash(r.getSbn().getNotification().getChannelId());
}
/**
* @return Small hash of the group ID, respecting group override if present. 0 otherwise.
*/
int getGroupIdHash() {
- return smallHash(r.getSbn().getGroup());
+ return SmallHash.hash(r.getSbn().getGroup());
}
}
- // "Small" hashes will be in the range [0, MAX_HASH).
- int MAX_HASH = (1 << 13);
-
- /**
- * Maps in to the range [0, MAX_HASH), keeping similar values distinct.
- * @param in An arbitrary integer.
- * @return in mod MAX_HASH, signs chosen to stay in the range [0, MAX_HASH).
- */
- static int smallHash(int in) {
- return Math.floorMod(in, MAX_HASH);
- }
-
- /**
- * @return Small hash of the string, if non-null, or 0 otherwise.
- */
- static int smallHash(@Nullable String in) {
- return smallHash(Objects.hashCode(in));
- }
-
}