Skip to content

Commit

Permalink
[Android O] Check feature list initialized - fixes crash on upgrade
Browse files Browse the repository at this point in the history
- Previously it was crashing on getLegacyChannelIds when updating
channels on package replaced, because native wasn't loaded on checking
ChromeFeatureList.isEnabled.

- Now we only check if the flag is enabled if the feature list has
been initialized, avoiding the crash.

- If the feature list has not been initialized, we assume the feature
is enabled, and treat the Sites channel as a legacy channel that should
be deleted. This is safe even if the feature is actually disabled,
because the Sites channel will be recreated on first use.

Bug: 774289
Change-Id: I1f3661e70baea9a6bbbf7eab314ce2e8329bf762
Reviewed-on: https://chromium-review.googlesource.com/718616
Commit-Queue: Anita Woodruff <awdf@chromium.org>
Commit-Queue: Peter Beverloo <peter@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#508673}
  • Loading branch information
Anita Woodruff authored and Commit Bot committed Oct 13, 2017
1 parent d36976a commit ad2b49f
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,11 @@ static List<String> getLegacyChannelIds() {
List<String> legacyChannels = new ArrayList<>(Arrays.asList(LEGACY_CHANNEL_IDS));
// When the SiteNotificationChannels feature is enabled, we use dynamically-created channels
// for different sites, so we no longer need the generic predefined 'Sites' channel.
// Err on the side of deleting it if we can't tell if the flag is enabled, because it will
// always be recreated if it is actually required.
// TODO(crbug.com/758553) Put CHANNEL_ID_SITES in LEGACY_CHANNEL_IDS once flag is gone.
if (ChromeFeatureList.isEnabled(ChromeFeatureList.SITE_NOTIFICATION_CHANNELS)) {
if (!ChromeFeatureList.isInitialized()
|| ChromeFeatureList.isEnabled(ChromeFeatureList.SITE_NOTIFICATION_CHANNELS)) {
legacyChannels.add(ChannelDefinitions.CHANNEL_ID_SITES);
}
return legacyChannels;
Expand Down

0 comments on commit ad2b49f

Please sign in to comment.