소스 검색

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 <t@grobox.de>
Torsten Grote 4 년 전
부모
커밋
8fbfc9028a
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      src/main/java/com/owncloud/android/files/services/FileUploader.java

+ 3 - 0
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;