Browse Source

android: fix crash if notification is null

I cannot see a path leading to it being null, but Crashlytics demonstrated it's
possible (so far in a small subset of old devices). Be defensive then.
master
Saúl Ibarra Corretgé 6 years ago
parent
commit
f8a049759d

+ 7
- 2
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetOngoingConferenceService.java View File

@@ -82,8 +82,13 @@ public class JitsiMeetOngoingConferenceService extends Service
82 82
         final String action = intent.getAction();
83 83
         if (action.equals(Actions.START)) {
84 84
             Notification notification = OngoingNotification.buildOngoingConferenceNotification();
85
-            startForeground(OngoingNotification.NOTIFICATION_ID, notification);
86
-            Log.i(TAG, "Service started");
85
+            if (notification == null) {
86
+                stopSelf();
87
+                Log.w(TAG, "Couldn't start service, notification is null");
88
+            } else {
89
+                startForeground(OngoingNotification.NOTIFICATION_ID, notification);
90
+                Log.i(TAG, "Service started");
91
+            }
87 92
         } else if (action.equals(Actions.HANGUP)) {
88 93
             Log.i(TAG, "Hangup requested");
89 94
             // Abort all ongoing calls

Loading…
Cancel
Save