Commit 840a403e authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Trap SecurityException with preemptive mobile activation

Older android versions require additional permission (as a bug) which we
do not want to request. Instead we will trap the exception and ignore
the failure.

Fixed: 1119435
Change-Id: I6377f4e2f910a5a8ab37af12235548420934f8b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2364749
Commit-Queue: Ken Rockot <rockot@google.com>
Commit-Queue: Zhongyi Shi <zhongyi@chromium.org>
Reviewed-by: default avatarZhongyi Shi <zhongyi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799802}
parent 7b228b81
...@@ -47,12 +47,18 @@ public class NetworkActivationRequest extends NetworkCallback { ...@@ -47,12 +47,18 @@ public class NetworkActivationRequest extends NetworkCallback {
mNativePtr = nativePtr; mNativePtr = nativePtr;
if (mConnectivityManager == null) return; if (mConnectivityManager == null) return;
try {
mConnectivityManager.requestNetwork( mConnectivityManager.requestNetwork(
new NetworkRequest.Builder() new NetworkRequest.Builder()
.addTransportType(transportType) .addTransportType(transportType)
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.build(), .build(),
this); this);
} catch (SecurityException e) {
// On some older devices the CHANGE_NETWORK_STATE permission is not sufficient to allow
// use of {@code requestNetwork} above and it will throw a SecurityException. Do nothing
// in this case.
}
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment