Skip to content

Commit

Permalink
Workaround ConnectivityManager SecurityException on Android 11
Browse files Browse the repository at this point in the history
Issue: #9002
PiperOrigin-RevId: 395221648
  • Loading branch information
ojw28 authored and christosts committed Sep 16, 2021
1 parent aa88e0b commit 140e110
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
* Request smaller decoder input buffers for Dolby Vision. This fixes an
issue that could cause UHD Dolby Vision playbacks to fail on some
devices, including Amazon Fire TV 4K.
* Downloads and caching:
* Workaround platform issue that can cause a `SecurityException` to be
thrown from `Requirements.isInternetConnectivityValidated` on devices
running Android 11
([#9002](https://github.com/google/ExoPlayer/issues/9002)).
* Cast extension:
* Implement `CastPlayer.setPlaybackParameters(PlaybackParameters)` to
support setting the playback speed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,17 @@ private static boolean isInternetConnectivityValidated(ConnectivityManager conne
if (activeNetwork == null) {
return false;
}
@Nullable
NetworkCapabilities networkCapabilities =
connectivityManager.getNetworkCapabilities(activeNetwork);
return networkCapabilities != null
&& networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);

try {
@Nullable
NetworkCapabilities networkCapabilities =
connectivityManager.getNetworkCapabilities(activeNetwork);
return networkCapabilities != null
&& networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
} catch (SecurityException e) {
// Workaround for https://issuetracker.google.com/issues/175055271.
return true;
}
}

@Override
Expand Down

0 comments on commit 140e110

Please sign in to comment.