Skip to content

Commit

Permalink
Workaround ConnectivityManager SecurityException on Android 11
Browse files Browse the repository at this point in the history
#exofixit
#minor-release
Issue: #9002
PiperOrigin-RevId: 395221648
  • Loading branch information
ojw28 authored and icbaker committed Sep 7, 2021
1 parent 5183eaa commit 2e21208
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 @@ -287,6 +287,11 @@
([#9183](https://github.com/google/ExoPlayer/issues/9183)).
* Allow the timeout to be customised via
`RtspMediaSource.Factory.setTimeoutMs`.
* 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)).

### 2.14.1 (2021-06-11)

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 2e21208

Please sign in to comment.