fix spotbugs and make PendingIntent immutable

Signed-off-by: Jonas Mayer <jonas.a.mayer@gmx.net>
This commit is contained in:
Jonas Mayer 2023-11-29 23:50:33 +01:00
parent 2a3d698b20
commit a30592ec9f
2 changed files with 7 additions and 3 deletions

View file

@ -207,7 +207,7 @@ class FilesUploadWorker(
context,
SecureRandom().nextInt(),
notificationActionIntent,
PendingIntent.FLAG_MUTABLE
PendingIntent.FLAG_IMMUTABLE
)
notificationBuilder

View file

@ -207,6 +207,8 @@ public class FileUploader extends Service
private Account mCurrentAccount;
private FileDataStorageManager mStorageManager;
private SecureRandom secureRandomGenerator = new SecureRandom();
@Inject UserAccountManager accountManager;
@Inject UploadsStorageManager mUploadsStorageManager;
@Inject ConnectivityService connectivityService;
@ -237,6 +239,7 @@ public class FileUploader extends Service
/**
* Service initialization
*/
@SuppressFBWarnings("ST")
@Override
public void onCreate() {
super.onCreate();
@ -284,6 +287,7 @@ public class FileUploader extends Service
/**
* Service clean up
*/
@SuppressFBWarnings("ST")
@Override
public void onDestroy() {
Log_OC.v(TAG, "Destroying service");
@ -713,7 +717,7 @@ public class FileUploader extends Service
notificationActionIntent.putExtra(EXTRA_REMOTE_PATH,upload.getRemotePath());
notificationActionIntent.setAction(ACTION_CANCEL_BROADCAST);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(),new SecureRandom().nextInt(),notificationActionIntent, PendingIntent.FLAG_MUTABLE);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(),secureRandomGenerator.nextInt(),notificationActionIntent, PendingIntent.FLAG_IMMUTABLE);
mLastPercent = 0;
mNotificationBuilder = NotificationUtils.newNotificationBuilder(this, viewThemeUtils);
mNotificationBuilder
@ -869,7 +873,7 @@ public class FileUploader extends Service
mNotificationBuilder.setContentText(content);
if (!uploadResult.isSuccess()) {
mNotificationManager.notify((new SecureRandom()).nextInt(), mNotificationBuilder.build());
mNotificationManager.notify(secureRandomGenerator.nextInt(), mNotificationBuilder.build());
}
}
}