resolve merge conflicts of c79a568 to nyc-dev-plus-aosp
Change-Id: I3ee02bc596f285fa41ffcafa882ae5997ef67d22
This commit is contained in:
@@ -119,12 +119,9 @@ public class NetworkInfo implements Parcelable {
|
|||||||
private String mReason;
|
private String mReason;
|
||||||
private String mExtraInfo;
|
private String mExtraInfo;
|
||||||
private boolean mIsFailover;
|
private boolean mIsFailover;
|
||||||
private boolean mIsRoaming;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether network connectivity is possible:
|
|
||||||
*/
|
|
||||||
private boolean mIsAvailable;
|
private boolean mIsAvailable;
|
||||||
|
private boolean mIsRoaming;
|
||||||
|
private boolean mIsMetered;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
@@ -139,8 +136,6 @@ public class NetworkInfo implements Parcelable {
|
|||||||
mSubtypeName = subtypeName;
|
mSubtypeName = subtypeName;
|
||||||
setDetailedState(DetailedState.IDLE, null, null);
|
setDetailedState(DetailedState.IDLE, null, null);
|
||||||
mState = State.UNKNOWN;
|
mState = State.UNKNOWN;
|
||||||
mIsAvailable = false; // until we're told otherwise, assume unavailable
|
|
||||||
mIsRoaming = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
@@ -156,8 +151,9 @@ public class NetworkInfo implements Parcelable {
|
|||||||
mReason = source.mReason;
|
mReason = source.mReason;
|
||||||
mExtraInfo = source.mExtraInfo;
|
mExtraInfo = source.mExtraInfo;
|
||||||
mIsFailover = source.mIsFailover;
|
mIsFailover = source.mIsFailover;
|
||||||
mIsRoaming = source.mIsRoaming;
|
|
||||||
mIsAvailable = source.mIsAvailable;
|
mIsAvailable = source.mIsAvailable;
|
||||||
|
mIsRoaming = source.mIsRoaming;
|
||||||
|
mIsMetered = source.mIsMetered;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,6 +325,30 @@ public class NetworkInfo implements Parcelable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if this network is metered. A network is classified as metered
|
||||||
|
* when the user is sensitive to heavy data usage on that connection due to
|
||||||
|
* monetary costs, data limitations or battery/performance issues. You
|
||||||
|
* should check this before doing large data transfers, and warn the user or
|
||||||
|
* delay the operation until another network is available.
|
||||||
|
*
|
||||||
|
* @return {@code true} if large transfers should be avoided, otherwise
|
||||||
|
* {@code false}.
|
||||||
|
*/
|
||||||
|
public boolean isMetered() {
|
||||||
|
synchronized (this) {
|
||||||
|
return mIsMetered;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@hide} */
|
||||||
|
@VisibleForTesting
|
||||||
|
public void setMetered(boolean isMetered) {
|
||||||
|
synchronized (this) {
|
||||||
|
mIsMetered = isMetered;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reports the current coarse-grained state of the network.
|
* Reports the current coarse-grained state of the network.
|
||||||
* @return the coarse-grained state
|
* @return the coarse-grained state
|
||||||
@@ -409,26 +429,21 @@ public class NetworkInfo implements Parcelable {
|
|||||||
append("], state: ").append(mState).append("/").append(mDetailedState).
|
append("], state: ").append(mState).append("/").append(mDetailedState).
|
||||||
append(", reason: ").append(mReason == null ? "(unspecified)" : mReason).
|
append(", reason: ").append(mReason == null ? "(unspecified)" : mReason).
|
||||||
append(", extra: ").append(mExtraInfo == null ? "(none)" : mExtraInfo).
|
append(", extra: ").append(mExtraInfo == null ? "(none)" : mExtraInfo).
|
||||||
append(", roaming: ").append(mIsRoaming).
|
|
||||||
append(", failover: ").append(mIsFailover).
|
append(", failover: ").append(mIsFailover).
|
||||||
append(", isAvailable: ").append(mIsAvailable).
|
append(", available: ").append(mIsAvailable).
|
||||||
|
append(", roaming: ").append(mIsRoaming).
|
||||||
|
append(", metered: ").append(mIsMetered).
|
||||||
append("]");
|
append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Implement the Parcelable interface
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Implement the Parcelable interface.
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
dest.writeInt(mNetworkType);
|
dest.writeInt(mNetworkType);
|
||||||
@@ -440,35 +455,34 @@ public class NetworkInfo implements Parcelable {
|
|||||||
dest.writeInt(mIsFailover ? 1 : 0);
|
dest.writeInt(mIsFailover ? 1 : 0);
|
||||||
dest.writeInt(mIsAvailable ? 1 : 0);
|
dest.writeInt(mIsAvailable ? 1 : 0);
|
||||||
dest.writeInt(mIsRoaming ? 1 : 0);
|
dest.writeInt(mIsRoaming ? 1 : 0);
|
||||||
|
dest.writeInt(mIsMetered ? 1 : 0);
|
||||||
dest.writeString(mReason);
|
dest.writeString(mReason);
|
||||||
dest.writeString(mExtraInfo);
|
dest.writeString(mExtraInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static final Creator<NetworkInfo> CREATOR = new Creator<NetworkInfo>() {
|
||||||
* Implement the Parcelable interface.
|
@Override
|
||||||
* @hide
|
public NetworkInfo createFromParcel(Parcel in) {
|
||||||
*/
|
int netType = in.readInt();
|
||||||
public static final Creator<NetworkInfo> CREATOR =
|
int subtype = in.readInt();
|
||||||
new Creator<NetworkInfo>() {
|
String typeName = in.readString();
|
||||||
public NetworkInfo createFromParcel(Parcel in) {
|
String subtypeName = in.readString();
|
||||||
int netType = in.readInt();
|
NetworkInfo netInfo = new NetworkInfo(netType, subtype, typeName, subtypeName);
|
||||||
int subtype = in.readInt();
|
netInfo.mState = State.valueOf(in.readString());
|
||||||
String typeName = in.readString();
|
netInfo.mDetailedState = DetailedState.valueOf(in.readString());
|
||||||
String subtypeName = in.readString();
|
netInfo.mIsFailover = in.readInt() != 0;
|
||||||
NetworkInfo netInfo = new NetworkInfo(netType, subtype, typeName, subtypeName);
|
netInfo.mIsAvailable = in.readInt() != 0;
|
||||||
netInfo.mState = State.valueOf(in.readString());
|
netInfo.mIsRoaming = in.readInt() != 0;
|
||||||
netInfo.mDetailedState = DetailedState.valueOf(in.readString());
|
netInfo.mIsMetered = in.readInt() != 0;
|
||||||
netInfo.mIsFailover = in.readInt() != 0;
|
netInfo.mReason = in.readString();
|
||||||
netInfo.mIsAvailable = in.readInt() != 0;
|
netInfo.mExtraInfo = in.readString();
|
||||||
netInfo.mIsRoaming = in.readInt() != 0;
|
return netInfo;
|
||||||
netInfo.mReason = in.readString();
|
}
|
||||||
netInfo.mExtraInfo = in.readString();
|
|
||||||
return netInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NetworkInfo[] newArray(int size) {
|
@Override
|
||||||
return new NetworkInfo[size];
|
public NetworkInfo[] newArray(int size) {
|
||||||
}
|
return new NetworkInfo[size];
|
||||||
};
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.os.Parcelable;
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public class NetworkState implements Parcelable {
|
public class NetworkState implements Parcelable {
|
||||||
|
public static final NetworkState EMPTY = new NetworkState(null, null, null, null, null, null);
|
||||||
|
|
||||||
public final NetworkInfo networkInfo;
|
public final NetworkInfo networkInfo;
|
||||||
public final LinkProperties linkProperties;
|
public final LinkProperties linkProperties;
|
||||||
|
|||||||
@@ -821,37 +821,25 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private NetworkState getFilteredNetworkState(int networkType, int uid) {
|
private NetworkState getFilteredNetworkState(int networkType, int uid) {
|
||||||
NetworkInfo info = null;
|
|
||||||
LinkProperties lp = null;
|
|
||||||
NetworkCapabilities nc = null;
|
|
||||||
Network network = null;
|
|
||||||
String subscriberId = null;
|
|
||||||
|
|
||||||
if (mLegacyTypeTracker.isTypeSupported(networkType)) {
|
if (mLegacyTypeTracker.isTypeSupported(networkType)) {
|
||||||
NetworkAgentInfo nai = mLegacyTypeTracker.getNetworkForType(networkType);
|
final NetworkAgentInfo nai = mLegacyTypeTracker.getNetworkForType(networkType);
|
||||||
|
final NetworkState state;
|
||||||
if (nai != null) {
|
if (nai != null) {
|
||||||
synchronized (nai) {
|
state = nai.getNetworkState();
|
||||||
info = new NetworkInfo(nai.networkInfo);
|
state.networkInfo.setType(networkType);
|
||||||
lp = new LinkProperties(nai.linkProperties);
|
|
||||||
nc = new NetworkCapabilities(nai.networkCapabilities);
|
|
||||||
// Network objects are outwardly immutable so there is no point to duplicating.
|
|
||||||
// Duplicating also precludes sharing socket factories and connection pools.
|
|
||||||
network = nai.network;
|
|
||||||
subscriberId = (nai.networkMisc != null) ? nai.networkMisc.subscriberId : null;
|
|
||||||
}
|
|
||||||
info.setType(networkType);
|
|
||||||
} else {
|
} else {
|
||||||
info = new NetworkInfo(networkType, 0, getNetworkTypeName(networkType), "");
|
final NetworkInfo info = new NetworkInfo(networkType, 0,
|
||||||
|
getNetworkTypeName(networkType), "");
|
||||||
info.setDetailedState(NetworkInfo.DetailedState.DISCONNECTED, null, null);
|
info.setDetailedState(NetworkInfo.DetailedState.DISCONNECTED, null, null);
|
||||||
info.setIsAvailable(true);
|
info.setIsAvailable(true);
|
||||||
lp = new LinkProperties();
|
state = new NetworkState(info, new LinkProperties(), new NetworkCapabilities(),
|
||||||
nc = new NetworkCapabilities();
|
null, null, null);
|
||||||
network = null;
|
|
||||||
}
|
}
|
||||||
info = getFilteredNetworkInfo(info, lp, uid);
|
filterNetworkStateForUid(state, uid);
|
||||||
|
return state;
|
||||||
|
} else {
|
||||||
|
return NetworkState.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new NetworkState(info, lp, nc, network, subscriberId, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private NetworkAgentInfo getNetworkAgentInfoForNetwork(Network network) {
|
private NetworkAgentInfo getNetworkAgentInfoForNetwork(Network network) {
|
||||||
@@ -861,7 +849,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
synchronized (mNetworkForNetId) {
|
synchronized (mNetworkForNetId) {
|
||||||
return mNetworkForNetId.get(network.netId);
|
return mNetworkForNetId.get(network.netId);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
private Network[] getVpnUnderlyingNetworks(int uid) {
|
private Network[] getVpnUnderlyingNetworks(int uid) {
|
||||||
if (!mLockdownEnabled) {
|
if (!mLockdownEnabled) {
|
||||||
@@ -877,12 +865,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private NetworkState getUnfilteredActiveNetworkState(int uid) {
|
private NetworkState getUnfilteredActiveNetworkState(int uid) {
|
||||||
NetworkInfo info = null;
|
|
||||||
LinkProperties lp = null;
|
|
||||||
NetworkCapabilities nc = null;
|
|
||||||
Network network = null;
|
|
||||||
String subscriberId = null;
|
|
||||||
|
|
||||||
NetworkAgentInfo nai = getDefaultNetwork();
|
NetworkAgentInfo nai = getDefaultNetwork();
|
||||||
|
|
||||||
final Network[] networks = getVpnUnderlyingNetworks(uid);
|
final Network[] networks = getVpnUnderlyingNetworks(uid);
|
||||||
@@ -900,18 +882,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nai != null) {
|
if (nai != null) {
|
||||||
synchronized (nai) {
|
return nai.getNetworkState();
|
||||||
info = new NetworkInfo(nai.networkInfo);
|
} else {
|
||||||
lp = new LinkProperties(nai.linkProperties);
|
return NetworkState.EMPTY;
|
||||||
nc = new NetworkCapabilities(nai.networkCapabilities);
|
|
||||||
// Network objects are outwardly immutable so there is no point to duplicating.
|
|
||||||
// Duplicating also precludes sharing socket factories and connection pools.
|
|
||||||
network = nai.network;
|
|
||||||
subscriberId = (nai.networkMisc != null) ? nai.networkMisc.subscriberId : null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new NetworkState(info, lp, nc, network, subscriberId, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -952,21 +926,29 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a filtered {@link NetworkInfo}, potentially marked
|
* Apply any relevant filters to {@link NetworkState} for the given UID. For
|
||||||
* {@link DetailedState#BLOCKED} based on
|
* example, this may mark the network as {@link DetailedState#BLOCKED} based
|
||||||
* {@link #isNetworkWithLinkPropertiesBlocked}.
|
* on {@link #isNetworkWithLinkPropertiesBlocked}, or
|
||||||
|
* {@link NetworkInfo#isMetered()} based on network policies.
|
||||||
*/
|
*/
|
||||||
private NetworkInfo getFilteredNetworkInfo(NetworkInfo info, LinkProperties lp, int uid) {
|
private void filterNetworkStateForUid(NetworkState state, int uid) {
|
||||||
if (info != null && isNetworkWithLinkPropertiesBlocked(lp, uid)) {
|
if (state == null || state.networkInfo == null || state.linkProperties == null) return;
|
||||||
// network is blocked; clone and override state
|
|
||||||
info = new NetworkInfo(info);
|
if (isNetworkWithLinkPropertiesBlocked(state.linkProperties, uid)) {
|
||||||
info.setDetailedState(DetailedState.BLOCKED, null, null);
|
state.networkInfo.setDetailedState(DetailedState.BLOCKED, null, null);
|
||||||
}
|
}
|
||||||
if (info != null && mLockdownTracker != null) {
|
if (mLockdownTracker != null) {
|
||||||
info = mLockdownTracker.augmentNetworkInfo(info);
|
mLockdownTracker.augmentNetworkInfo(state.networkInfo);
|
||||||
if (VDBG) log("returning Locked NetworkInfo");
|
}
|
||||||
|
|
||||||
|
// TODO: apply metered state closer to NetworkAgentInfo
|
||||||
|
final long token = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
state.networkInfo.setMetered(mPolicyManager.isNetworkMetered(state));
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(token);
|
||||||
}
|
}
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -980,10 +962,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
public NetworkInfo getActiveNetworkInfo() {
|
public NetworkInfo getActiveNetworkInfo() {
|
||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
final int uid = Binder.getCallingUid();
|
final int uid = Binder.getCallingUid();
|
||||||
NetworkState state = getUnfilteredActiveNetworkState(uid);
|
final NetworkState state = getUnfilteredActiveNetworkState(uid);
|
||||||
NetworkInfo ni = getFilteredNetworkInfo(state.networkInfo, state.linkProperties, uid);
|
filterNetworkStateForUid(state, uid);
|
||||||
maybeLogBlockedNetworkInfo(ni, uid);
|
maybeLogBlockedNetworkInfo(state.networkInfo, uid);
|
||||||
return ni;
|
return state.networkInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1027,8 +1009,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
@Override
|
@Override
|
||||||
public NetworkInfo getActiveNetworkInfoForUid(int uid) {
|
public NetworkInfo getActiveNetworkInfoForUid(int uid) {
|
||||||
enforceConnectivityInternalPermission();
|
enforceConnectivityInternalPermission();
|
||||||
NetworkState state = getUnfilteredActiveNetworkState(uid);
|
final NetworkState state = getUnfilteredActiveNetworkState(uid);
|
||||||
return getFilteredNetworkInfo(state.networkInfo, state.linkProperties, uid);
|
filterNetworkStateForUid(state, uid);
|
||||||
|
return state.networkInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1039,12 +1022,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// A VPN is active, so we may need to return one of its underlying networks. This
|
// A VPN is active, so we may need to return one of its underlying networks. This
|
||||||
// information is not available in LegacyTypeTracker, so we have to get it from
|
// information is not available in LegacyTypeTracker, so we have to get it from
|
||||||
// getUnfilteredActiveNetworkState.
|
// getUnfilteredActiveNetworkState.
|
||||||
NetworkState state = getUnfilteredActiveNetworkState(uid);
|
final NetworkState state = getUnfilteredActiveNetworkState(uid);
|
||||||
if (state.networkInfo != null && state.networkInfo.getType() == networkType) {
|
if (state.networkInfo != null && state.networkInfo.getType() == networkType) {
|
||||||
return getFilteredNetworkInfo(state.networkInfo, state.linkProperties, uid);
|
filterNetworkStateForUid(state, uid);
|
||||||
|
return state.networkInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NetworkState state = getFilteredNetworkState(networkType, uid);
|
final NetworkState state = getFilteredNetworkState(networkType, uid);
|
||||||
return state.networkInfo;
|
return state.networkInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1052,15 +1036,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
public NetworkInfo getNetworkInfoForNetwork(Network network) {
|
public NetworkInfo getNetworkInfoForNetwork(Network network) {
|
||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
final int uid = Binder.getCallingUid();
|
final int uid = Binder.getCallingUid();
|
||||||
NetworkInfo info = null;
|
final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
|
||||||
NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
|
|
||||||
if (nai != null) {
|
if (nai != null) {
|
||||||
synchronized (nai) {
|
final NetworkState state = nai.getNetworkState();
|
||||||
info = new NetworkInfo(nai.networkInfo);
|
filterNetworkStateForUid(state, uid);
|
||||||
info = getFilteredNetworkInfo(info, nai.linkProperties, uid);
|
return state.networkInfo;
|
||||||
}
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1222,12 +1205,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
for (Network network : getAllNetworks()) {
|
for (Network network : getAllNetworks()) {
|
||||||
final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
|
final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
|
||||||
if (nai != null) {
|
if (nai != null) {
|
||||||
synchronized (nai) {
|
result.add(nai.getNetworkState());
|
||||||
final String subscriberId = (nai.networkMisc != null)
|
|
||||||
? nai.networkMisc.subscriberId : null;
|
|
||||||
result.add(new NetworkState(nai.networkInfo, nai.linkProperties,
|
|
||||||
nai.networkCapabilities, network, subscriberId, null));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result.toArray(new NetworkState[result.size()]);
|
return result.toArray(new NetworkState[result.size()]);
|
||||||
@@ -1255,24 +1233,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
@Override
|
@Override
|
||||||
public boolean isActiveNetworkMetered() {
|
public boolean isActiveNetworkMetered() {
|
||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
final int uid = Binder.getCallingUid();
|
|
||||||
final long token = Binder.clearCallingIdentity();
|
|
||||||
try {
|
|
||||||
return isActiveNetworkMeteredUnchecked(uid);
|
|
||||||
} finally {
|
|
||||||
Binder.restoreCallingIdentity(token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isActiveNetworkMeteredUnchecked(int uid) {
|
final NetworkInfo info = getActiveNetworkInfo();
|
||||||
final NetworkState state = getUnfilteredActiveNetworkState(uid);
|
return (info != null) ? info.isMetered() : false;
|
||||||
if (state.networkInfo != null) {
|
|
||||||
try {
|
|
||||||
return mPolicyManager.isNetworkMetered(state);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private INetworkManagementEventObserver mDataActivityObserver = new BaseNetworkObserver() {
|
private INetworkManagementEventObserver mDataActivityObserver = new BaseNetworkObserver() {
|
||||||
@@ -1490,7 +1453,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
private Intent makeGeneralIntent(NetworkInfo info, String bcastType) {
|
private Intent makeGeneralIntent(NetworkInfo info, String bcastType) {
|
||||||
if (mLockdownTracker != null) {
|
if (mLockdownTracker != null) {
|
||||||
info = mLockdownTracker.augmentNetworkInfo(info);
|
info = new NetworkInfo(info);
|
||||||
|
mLockdownTracker.augmentNetworkInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(bcastType);
|
Intent intent = new Intent(bcastType);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.net.NetworkCapabilities;
|
|||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.NetworkMisc;
|
import android.net.NetworkMisc;
|
||||||
import android.net.NetworkRequest;
|
import android.net.NetworkRequest;
|
||||||
|
import android.net.NetworkState;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
@@ -247,6 +248,17 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> {
|
|||||||
currentScore = newScore;
|
currentScore = newScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NetworkState getNetworkState() {
|
||||||
|
synchronized (this) {
|
||||||
|
// Network objects are outwardly immutable so there is no point to duplicating.
|
||||||
|
// Duplicating also precludes sharing socket factories and connection pools.
|
||||||
|
final String subscriberId = (networkMisc != null) ? networkMisc.subscriberId : null;
|
||||||
|
return new NetworkState(new NetworkInfo(networkInfo),
|
||||||
|
new LinkProperties(linkProperties),
|
||||||
|
new NetworkCapabilities(networkCapabilities), network, subscriberId, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "NetworkAgentInfo{ ni{" + networkInfo + "} " +
|
return "NetworkAgentInfo{ ni{" + networkInfo + "} " +
|
||||||
"network{" + network + "} nethandle{" + network.getNetworkHandle() + "} " +
|
"network{" + network + "} nethandle{" + network.getNetworkHandle() + "} " +
|
||||||
|
|||||||
Reference in New Issue
Block a user