[FUI22] Support getAllNetworkStateSnapshot

Currently, ConnectivityService has getAllNetworkState but it is
not ideal to expose as system API since the plan is to get rid
of NetworkState. Thus, create a new one that returns
NetworkStateSnapshot to fulfill the needs.

Note the original getAllNetworkState cannot be deleted now since
it has @UnsupportedAppUsage annotation.

Test: atest FrameworksNetTests
Bug: 174123988
Change-Id: Icddd434552b0e9ecbc8299e7242ec88cf3145aca
This commit is contained in:
junyulai
2021-03-03 12:09:05 +08:00
parent 1984fb1cb0
commit 41c85f50c4

View File

@@ -24,6 +24,8 @@ import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import com.android.net.module.util.NetworkIdentityUtils;
import java.util.Objects;
/**
@@ -124,4 +126,15 @@ public final class NetworkStateSnapshot implements Parcelable {
public int hashCode() {
return Objects.hash(network, networkCapabilities, linkProperties, subscriberId, legacyType);
}
@Override
public String toString() {
return "NetworkStateSnapshot{"
+ "network=" + network
+ ", networkCapabilities=" + networkCapabilities
+ ", linkProperties=" + linkProperties
+ ", subscriberId='" + NetworkIdentityUtils.scrubSubscriberId(subscriberId) + '\''
+ ", legacyType=" + legacyType
+ '}';
}
}