From 8fbfc9028a2257ad44ef7b6875ae19c3d04c10bf Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Mon, 17 Aug 2020 11:01:57 -0300 Subject: [PATCH] Ensure that mNotificationManager is not null when updating transfer progress This might happen, if the FileUploader service is being destroyed, so mNotificationManager is set to null. The applied fix has been used in a couple of other places in this file as well, so it is at least consistent. Signed-off-by: Torsten Grote --- .../java/com/owncloud/android/files/services/FileUploader.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/owncloud/android/files/services/FileUploader.java b/src/main/java/com/owncloud/android/files/services/FileUploader.java index 131dbe64d3..2c75a3dc78 100644 --- a/src/main/java/com/owncloud/android/files/services/FileUploader.java +++ b/src/main/java/com/owncloud/android/files/services/FileUploader.java @@ -715,6 +715,9 @@ public class FileUploader extends Service String fileName = filePath.substring(filePath.lastIndexOf(FileUtils.PATH_SEPARATOR) + 1); String text = String.format(getString(R.string.uploader_upload_in_progress_content), percent, fileName); mNotificationBuilder.setContentText(text); + if (mNotificationManager == null) { + mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + } mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotificationBuilder.build()); } mLastPercent = percent;