From bbeacbfc57a73e9ac5c69324b0b8e7b2b693e85d Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 16 Jan 2019 14:59:20 +0100 Subject: [PATCH] improve usage of random, ignore findbugs since notification Ids are fine to be predictable Signed-off-by: Andy Scherzinger --- .../owncloud/android/jobs/MediaFoldersDetectionJob.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/owncloud/android/jobs/MediaFoldersDetectionJob.java b/src/main/java/com/owncloud/android/jobs/MediaFoldersDetectionJob.java index 2431bd16c504..099ebdd6f463 100644 --- a/src/main/java/com/owncloud/android/jobs/MediaFoldersDetectionJob.java +++ b/src/main/java/com/owncloud/android/jobs/MediaFoldersDetectionJob.java @@ -56,6 +56,7 @@ import androidx.annotation.NonNull; import androidx.core.app.NotificationCompat; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; public class MediaFoldersDetectionJob extends Job { public static final String TAG = "MediaFoldersDetectionJob"; @@ -69,6 +70,12 @@ public class MediaFoldersDetectionJob extends Job { private static final String DISABLE_DETECTION_CLICK = "DISABLE_DETECTION_CLICK"; + @SuppressFBWarnings( + value = "PREDICTABLE_RANDOM", + justification = "Only used for notification id, so predictability is no issue here." + ) + private Random randomId = new Random(); + @NonNull @Override protected Result onRunJob(@NonNull Params params) { @@ -150,7 +157,7 @@ protected Result onRunJob(@NonNull Params params) { } private void sendNotification(String contentTitle, String subtitle, Account account, String path, int type) { - int notificationId = new Random().nextInt(); + int notificationId = randomId.nextInt(); Context context = getContext(); Intent intent = new Intent(getContext(), SyncedFoldersActivity.class);