Loading core/java/android/net/NetworkRequest.java +7 −8 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package android.net; import android.os.Parcel; import android.os.Parcelable; import java.util.Objects; /** * Defines a request for a network, made through {@link NetworkRequest.Builder} and used * to request a network via {@link ConnectivityManager#requestNetwork} or listen for changes Loading Loading @@ -264,7 +266,7 @@ public class NetworkRequest implements Parcelable { dest.writeParcelable(networkCapabilities, flags); dest.writeInt(legacyType); dest.writeInt(requestId); // type intentionally not preserved across process boundaries. dest.writeString(type.name()); } public static final Creator<NetworkRequest> CREATOR = new Creator<NetworkRequest>() { Loading @@ -272,8 +274,8 @@ public class NetworkRequest implements Parcelable { NetworkCapabilities nc = (NetworkCapabilities)in.readParcelable(null); int legacyType = in.readInt(); int requestId = in.readInt(); // type intentionally not preserved across process boundaries. NetworkRequest result = new NetworkRequest(nc, legacyType, requestId, Type.NONE); Type type = Type.valueOf(in.readString()); // IllegalArgumentException if invalid. NetworkRequest result = new NetworkRequest(nc, legacyType, requestId, type); return result; } public NetworkRequest[] newArray(int size) { Loading Loading @@ -311,13 +313,10 @@ public class NetworkRequest implements Parcelable { return (that.legacyType == this.legacyType && that.requestId == this.requestId && that.type == this.type && ((that.networkCapabilities == null && this.networkCapabilities == null) || (that.networkCapabilities != null && that.networkCapabilities.equals(this.networkCapabilities)))); Objects.equals(that.networkCapabilities, this.networkCapabilities)); } public int hashCode() { return requestId + (legacyType * 1013) + (networkCapabilities.hashCode() * 1051) + type.hashCode() * 17; return Objects.hash(requestId, legacyType, networkCapabilities, type); } } services/core/java/com/android/server/ConnectivityService.java +10 −9 Original line number Diff line number Diff line Loading @@ -3839,6 +3839,13 @@ public class ConnectivityService extends IConnectivityManager.Stub } } private void ensureNetworkRequestHasType(NetworkRequest request) { if (request.type == NetworkRequest.Type.NONE) { throw new IllegalArgumentException( "All NetworkRequests in ConnectivityService must have a type"); } } /** * Tracks info about the requester. * Also used to notice when the calling process dies so we can self-expire Loading @@ -3854,7 +3861,7 @@ public class ConnectivityService extends IConnectivityManager.Stub NetworkRequestInfo(NetworkRequest r, PendingIntent pi) { request = r; ensureRequestHasType(); ensureNetworkRequestHasType(request); mPendingIntent = pi; messenger = null; mBinder = null; Loading @@ -3867,7 +3874,7 @@ public class ConnectivityService extends IConnectivityManager.Stub super(); messenger = m; request = r; ensureRequestHasType(); ensureNetworkRequestHasType(request); mBinder = binder; mPid = getCallingPid(); mUid = getCallingUid(); Loading @@ -3881,13 +3888,6 @@ public class ConnectivityService extends IConnectivityManager.Stub } } private void ensureRequestHasType() { if (request.type == NetworkRequest.Type.NONE) { throw new IllegalArgumentException( "All NetworkRequests in ConnectivityService must have a type"); } } private void enforceRequestCountLimit() { synchronized (mUidToNetworkRequestCount) { int networkRequests = mUidToNetworkRequestCount.get(mUid, 0) + 1; Loading Loading @@ -4141,6 +4141,7 @@ public class ConnectivityService extends IConnectivityManager.Stub @Override public void releaseNetworkRequest(NetworkRequest networkRequest) { ensureNetworkRequestHasType(networkRequest); mHandler.sendMessage(mHandler.obtainMessage(EVENT_RELEASE_NETWORK_REQUEST, getCallingUid(), 0, networkRequest)); } Loading Loading
core/java/android/net/NetworkRequest.java +7 −8 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package android.net; import android.os.Parcel; import android.os.Parcelable; import java.util.Objects; /** * Defines a request for a network, made through {@link NetworkRequest.Builder} and used * to request a network via {@link ConnectivityManager#requestNetwork} or listen for changes Loading Loading @@ -264,7 +266,7 @@ public class NetworkRequest implements Parcelable { dest.writeParcelable(networkCapabilities, flags); dest.writeInt(legacyType); dest.writeInt(requestId); // type intentionally not preserved across process boundaries. dest.writeString(type.name()); } public static final Creator<NetworkRequest> CREATOR = new Creator<NetworkRequest>() { Loading @@ -272,8 +274,8 @@ public class NetworkRequest implements Parcelable { NetworkCapabilities nc = (NetworkCapabilities)in.readParcelable(null); int legacyType = in.readInt(); int requestId = in.readInt(); // type intentionally not preserved across process boundaries. NetworkRequest result = new NetworkRequest(nc, legacyType, requestId, Type.NONE); Type type = Type.valueOf(in.readString()); // IllegalArgumentException if invalid. NetworkRequest result = new NetworkRequest(nc, legacyType, requestId, type); return result; } public NetworkRequest[] newArray(int size) { Loading Loading @@ -311,13 +313,10 @@ public class NetworkRequest implements Parcelable { return (that.legacyType == this.legacyType && that.requestId == this.requestId && that.type == this.type && ((that.networkCapabilities == null && this.networkCapabilities == null) || (that.networkCapabilities != null && that.networkCapabilities.equals(this.networkCapabilities)))); Objects.equals(that.networkCapabilities, this.networkCapabilities)); } public int hashCode() { return requestId + (legacyType * 1013) + (networkCapabilities.hashCode() * 1051) + type.hashCode() * 17; return Objects.hash(requestId, legacyType, networkCapabilities, type); } }
services/core/java/com/android/server/ConnectivityService.java +10 −9 Original line number Diff line number Diff line Loading @@ -3839,6 +3839,13 @@ public class ConnectivityService extends IConnectivityManager.Stub } } private void ensureNetworkRequestHasType(NetworkRequest request) { if (request.type == NetworkRequest.Type.NONE) { throw new IllegalArgumentException( "All NetworkRequests in ConnectivityService must have a type"); } } /** * Tracks info about the requester. * Also used to notice when the calling process dies so we can self-expire Loading @@ -3854,7 +3861,7 @@ public class ConnectivityService extends IConnectivityManager.Stub NetworkRequestInfo(NetworkRequest r, PendingIntent pi) { request = r; ensureRequestHasType(); ensureNetworkRequestHasType(request); mPendingIntent = pi; messenger = null; mBinder = null; Loading @@ -3867,7 +3874,7 @@ public class ConnectivityService extends IConnectivityManager.Stub super(); messenger = m; request = r; ensureRequestHasType(); ensureNetworkRequestHasType(request); mBinder = binder; mPid = getCallingPid(); mUid = getCallingUid(); Loading @@ -3881,13 +3888,6 @@ public class ConnectivityService extends IConnectivityManager.Stub } } private void ensureRequestHasType() { if (request.type == NetworkRequest.Type.NONE) { throw new IllegalArgumentException( "All NetworkRequests in ConnectivityService must have a type"); } } private void enforceRequestCountLimit() { synchronized (mUidToNetworkRequestCount) { int networkRequests = mUidToNetworkRequestCount.get(mUid, 0) + 1; Loading Loading @@ -4141,6 +4141,7 @@ public class ConnectivityService extends IConnectivityManager.Stub @Override public void releaseNetworkRequest(NetworkRequest networkRequest) { ensureNetworkRequestHasType(networkRequest); mHandler.sendMessage(mHandler.obtainMessage(EVENT_RELEASE_NETWORK_REQUEST, getCallingUid(), 0, networkRequest)); } Loading