Merge "Rename *Iface* APIs to *Interface*" into sc-dev

This commit is contained in:
Aaron Huang
2021-04-29 03:32:16 +00:00
committed by Android (Google) Code Review
5 changed files with 20 additions and 20 deletions

View File

@@ -223,9 +223,9 @@ package android.net {
public final class UnderlyingNetworkInfo implements android.os.Parcelable {
ctor public UnderlyingNetworkInfo(int, @NonNull String, @NonNull java.util.List<java.lang.String>);
method public int describeContents();
method @NonNull public String getIface();
method @NonNull public String getInterface();
method public int getOwnerUid();
method @NonNull public java.util.List<java.lang.String> getUnderlyingIfaces();
method @NonNull public java.util.List<java.lang.String> getUnderlyingInterfaces();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.net.UnderlyingNetworkInfo> CREATOR;
}

View File

@@ -71,13 +71,13 @@ public final class UnderlyingNetworkInfo implements Parcelable {
/** Get the interface name of this network. */
@NonNull
public String getIface() {
public String getInterface() {
return mIface;
}
/** Get the names of the interfaces underlying this network. */
@NonNull
public List<String> getUnderlyingIfaces() {
public List<String> getUnderlyingInterfaces() {
return mUnderlyingIfaces;
}
@@ -124,8 +124,8 @@ public final class UnderlyingNetworkInfo implements Parcelable {
if (!(o instanceof UnderlyingNetworkInfo)) return false;
final UnderlyingNetworkInfo that = (UnderlyingNetworkInfo) o;
return mOwnerUid == that.getOwnerUid()
&& Objects.equals(mIface, that.getIface())
&& Objects.equals(mUnderlyingIfaces, that.getUnderlyingIfaces());
&& Objects.equals(mIface, that.getInterface())
&& Objects.equals(mUnderlyingIfaces, that.getUnderlyingInterfaces());
}
@Override

View File

@@ -382,8 +382,8 @@ public class NetworkStatsFactory {
// Migrate data usage over a VPN to the TUN network.
for (UnderlyingNetworkInfo info : vpnArray) {
delta.migrateTun(info.getOwnerUid(), info.getIface(),
info.getUnderlyingIfaces());
delta.migrateTun(info.getOwnerUid(), info.getInterface(),
info.getUnderlyingInterfaces());
// Filter out debug entries as that may lead to over counting.
delta.filterDebugEntries();
}

View File

@@ -36,15 +36,15 @@ class UnderlyingNetworkInfoTest {
@Test
fun testParcelUnparcel() {
val testInfo = UnderlyingNetworkInfo(TEST_OWNER_UID, TEST_IFACE, TEST_IFACE_LIST)
assertEquals(TEST_OWNER_UID, testInfo.ownerUid)
assertEquals(TEST_IFACE, testInfo.iface)
assertEquals(TEST_IFACE_LIST, testInfo.underlyingIfaces)
assertEquals(TEST_OWNER_UID, testInfo.getOwnerUid())
assertEquals(TEST_IFACE, testInfo.getInterface())
assertEquals(TEST_IFACE_LIST, testInfo.getUnderlyingInterfaces())
assertParcelSane(testInfo, 3)
val emptyInfo = UnderlyingNetworkInfo(0, String(), listOf())
assertEquals(0, emptyInfo.ownerUid)
assertEquals(String(), emptyInfo.iface)
assertEquals(listOf(), emptyInfo.underlyingIfaces)
assertEquals(0, emptyInfo.getOwnerUid())
assertEquals(String(), emptyInfo.getInterface())
assertEquals(listOf(), emptyInfo.getUnderlyingInterfaces())
assertParcelSane(emptyInfo, 3)
}
}

View File

@@ -5898,9 +5898,9 @@ public class ConnectivityServiceTest {
assertEquals("Should have exactly one VPN:", 1, infos.length);
UnderlyingNetworkInfo info = infos[0];
assertEquals("Unexpected VPN owner:", (int) vpnUid, info.getOwnerUid());
assertEquals("Unexpected VPN interface:", vpnIfname, info.getIface());
assertEquals("Unexpected VPN interface:", vpnIfname, info.getInterface());
assertSameElementsNoDuplicates(underlyingIfaces,
info.getUnderlyingIfaces().toArray(new String[0]));
info.getUnderlyingInterfaces().toArray(new String[0]));
} else {
assertEquals(0, infos.length);
return;
@@ -6044,8 +6044,8 @@ public class ConnectivityServiceTest {
// network for the VPN...
verify(mStatsManager, never()).notifyNetworkStatus(any(List.class),
any(List.class), any() /* anyString() doesn't match null */,
argThat(infos -> infos.get(0).getUnderlyingIfaces().size() == 1
&& WIFI_IFNAME.equals(infos.get(0).getUnderlyingIfaces().get(0))));
argThat(infos -> infos.get(0).getUnderlyingInterfaces().size() == 1
&& WIFI_IFNAME.equals(infos.get(0).getUnderlyingInterfaces().get(0))));
verifyNoMoreInteractions(mStatsManager);
reset(mStatsManager);
@@ -6059,8 +6059,8 @@ public class ConnectivityServiceTest {
waitForIdle();
verify(mStatsManager).notifyNetworkStatus(any(List.class),
any(List.class), any() /* anyString() doesn't match null */,
argThat(vpnInfos -> vpnInfos.get(0).getUnderlyingIfaces().size() == 1
&& WIFI_IFNAME.equals(vpnInfos.get(0).getUnderlyingIfaces().get(0))));
argThat(vpnInfos -> vpnInfos.get(0).getUnderlyingInterfaces().size() == 1
&& WIFI_IFNAME.equals(vpnInfos.get(0).getUnderlyingInterfaces().get(0))));
mEthernetNetworkAgent.disconnect();
waitForIdle();
reset(mStatsManager);