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
         final String action = intent.getAction();
82
         final String action = intent.getAction();
83
         if (action.equals(Actions.START)) {
83
         if (action.equals(Actions.START)) {
84
             Notification notification = OngoingNotification.buildOngoingConferenceNotification();
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
         } else if (action.equals(Actions.HANGUP)) {
92
         } else if (action.equals(Actions.HANGUP)) {
88
             Log.i(TAG, "Hangup requested");
93
             Log.i(TAG, "Hangup requested");
89
             // Abort all ongoing calls
94
             // Abort all ongoing calls

Loading…
Cancel
Save