Also update SharedPreferences with background media capturing enabled
We use SharedPreferences to determine whether to enable the media
notification service. Therefore, we should also update it when
background media capturing isn enabled.
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/MediaCaptureNotificationServiceImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/media/MediaCaptureNotificationServiceImpl.java
index 060c323..7fa35910 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/media/MediaCaptureNotificationServiceImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/media/MediaCaptureNotificationServiceImpl.java
@@ -152,6 +152,10 @@
if (notificationIds == null) return;
Iterator<String> iterator = notificationIds.iterator();
while (iterator.hasNext()) {
+ // When background media capturing is enabled, this operation is a no-op because a
+ // foreground service handles notification updates. We avoid calling
+ // isBackgroundMediaCapturingEnabled() here because this code may execute during early
+ // startup before the JNI library is initialized.
mNotificationManager.cancel(NOTIFICATION_NAMESPACE, Integer.parseInt(iterator.next()));
}
mSharedPreferences.removeKey(ChromePreferenceKeys.MEDIA_WEBRTC_NOTIFICATION_IDS);
@@ -246,8 +250,8 @@
// by the foreground service. If disabled, we have to cancel the notification
// manually.
mNotificationManager.cancel(NOTIFICATION_NAMESPACE, notificationId);
- updateSharedPreferencesEntry(notificationId, true);
}
+ updateSharedPreferencesEntry(notificationId, true);
}
}
@@ -327,8 +331,8 @@
mNotifications.add(new Pair<>(notificationId, notification));
} else {
mNotificationManager.notify(notification);
- updateSharedPreferencesEntry(notificationId, false);
}
+ updateSharedPreferencesEntry(notificationId, false);
NotificationUmaTracker.getInstance()
.onNotificationShown(
NotificationUmaTracker.SystemNotificationType.MEDIA_CAPTURE,
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Also update SharedPreferences with background media capturing enabled
We use SharedPreferences to determine whether to enable the media
notification service. Therefore, we should also update it when
background media capturing is enabled.
Hi Grace and Colin,
I made a mistake, we should always update shard preference since we use it to determine whether to start service. We can just remove `isBackgroundMediaCapturingEnabled()` from `cancelPreviousWebRtcNotifications()` to avoid crash. It is ok since `mNotificationManager.cancel()` will be non-op because we use foreground service to handle notification.
Sorry again for the inconvenience.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Also - is there anyone else who has or can grow expertise in this code? I don't really have any familiarity here, and it sounds like Grace doesn't have much either IIUC.