Ignore SecurityException in getNetworkCapabilities
A SecurityException can be thrown when calling android.net.ConnectivityManager.getNetworkCapabilities. As discussed in https://crbug.com/1218536, this seems like a platform bug. Workaround the problem by ignoring the exception and returning null instead. Bug: 1218536 Change-Id: Ibf88aea64706177a78a5b75836acb91de00a599a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2966677 Reviewed-by: Paul Jensen <pauljensen@chromium.org> Commit-Queue: Yutaka Hirano <yhirano@chromium.org> Cr-Commit-Position: refs/heads/master@{#894216}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
730b979fe1
commit
67e7a9d6c1
@ -360,7 +360,17 @@ public class NetworkChangeNotifierAutoDetect extends BroadcastReceiver {
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@VisibleForTesting
|
||||
protected NetworkCapabilities getNetworkCapabilities(Network network) {
|
||||
return mConnectivityManager.getNetworkCapabilities(network);
|
||||
final int retryCount = 2;
|
||||
for (int i = 0; i < retryCount; ++i) {
|
||||
// This try-catch is a workaround for https://crbug.com/1218536. We ignore
|
||||
// the exception intentionally.
|
||||
try {
|
||||
return mConnectivityManager.getNetworkCapabilities(network);
|
||||
} catch (SecurityException e) {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user