Remove JobInfo usage of NetworkRequest#networkCaps

NetworkRequest#networkCapabilities is an implementation detail (not part
of the NetworkRequest API); NetworkRequest has getters that return the
same information.

Bug: 174436414
Bug: 142281756
Test: m
Change-Id: I47e7ab1b887b2fe2dddef223bd7c66bdd290fc56
This commit is contained in:
Remi NGUYEN VAN
2020-11-30 11:35:13 +09:00
parent 011e74cc30
commit d2ef090419

View File

@@ -462,11 +462,11 @@ public class JobInfo implements Parcelable {
public @NetworkType int getNetworkType() { public @NetworkType int getNetworkType() {
if (networkRequest == null) { if (networkRequest == null) {
return NETWORK_TYPE_NONE; return NETWORK_TYPE_NONE;
} else if (networkRequest.networkCapabilities.hasCapability(NET_CAPABILITY_NOT_METERED)) { } else if (networkRequest.hasCapability(NET_CAPABILITY_NOT_METERED)) {
return NETWORK_TYPE_UNMETERED; return NETWORK_TYPE_UNMETERED;
} else if (networkRequest.networkCapabilities.hasCapability(NET_CAPABILITY_NOT_ROAMING)) { } else if (networkRequest.hasCapability(NET_CAPABILITY_NOT_ROAMING)) {
return NETWORK_TYPE_NOT_ROAMING; return NETWORK_TYPE_NOT_ROAMING;
} else if (networkRequest.networkCapabilities.hasTransport(TRANSPORT_CELLULAR)) { } else if (networkRequest.hasTransport(TRANSPORT_CELLULAR)) {
return NETWORK_TYPE_CELLULAR; return NETWORK_TYPE_CELLULAR;
} else { } else {
return NETWORK_TYPE_ANY; return NETWORK_TYPE_ANY;
@@ -1558,7 +1558,7 @@ public class JobInfo implements Parcelable {
if (isPersisted) { if (isPersisted) {
// We can't serialize network specifiers // We can't serialize network specifiers
if (networkRequest != null if (networkRequest != null
&& networkRequest.networkCapabilities.getNetworkSpecifier() != null) { && networkRequest.getNetworkSpecifier() != null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Network specifiers aren't supported for persistent jobs"); "Network specifiers aren't supported for persistent jobs");
} }