Remove unused getTetherStats
Before Android R, getTetherStats were used to collect tethering
iface stats of all clients who extends ITetheringStatsProvider,
which typically contains NetdTetheringStatsProvider and
OffloadController.
However, this always returns 0 since Android R, because:
1. OffloadController implemented NetworkStatsProvider and no
longer reports stats through getTetherStats.
2. NetdTetheringStatsProvider always return 0 by design since
non-offloaded iface tethering stats are already included
in native iface stats.
This change is a no-op refactoring to remove unused
getTetherStats and update test which is not pratical.
Fix for offloaded tethering stats will be in follow-up CLs.
Test: atest FrameworksNetTests TetheringTests
Bug: 162292214
Change-Id: Icd0717c5c2807ae3bd98626b897e4b148f142815
This commit is contained in:
@@ -35,7 +35,6 @@ import static android.net.NetworkStats.ROAMING_YES;
|
|||||||
import static android.net.NetworkStats.SET_ALL;
|
import static android.net.NetworkStats.SET_ALL;
|
||||||
import static android.net.NetworkStats.SET_DEFAULT;
|
import static android.net.NetworkStats.SET_DEFAULT;
|
||||||
import static android.net.NetworkStats.SET_FOREGROUND;
|
import static android.net.NetworkStats.SET_FOREGROUND;
|
||||||
import static android.net.NetworkStats.STATS_PER_IFACE;
|
|
||||||
import static android.net.NetworkStats.STATS_PER_UID;
|
import static android.net.NetworkStats.STATS_PER_UID;
|
||||||
import static android.net.NetworkStats.TAG_ALL;
|
import static android.net.NetworkStats.TAG_ALL;
|
||||||
import static android.net.NetworkStats.TAG_NONE;
|
import static android.net.NetworkStats.TAG_NONE;
|
||||||
@@ -1006,20 +1005,18 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
|
|
||||||
// Traffic seen by kernel counters (includes software tethering).
|
// Traffic seen by kernel counters (includes software tethering).
|
||||||
final NetworkStats ifaceStats = new NetworkStats(getElapsedRealtime(), 1)
|
final NetworkStats ifaceStats = new NetworkStats(getElapsedRealtime(), 1)
|
||||||
.insertEntry(TEST_IFACE, 1536L, 12L, 384L, 3L);
|
.insertEntry(TEST_IFACE, 2048L, 16L, 512L, 4L);
|
||||||
// Hardware tethering traffic, not seen by kernel counters.
|
// TODO: add hardware tethering traffic, not seen by kernel counters.
|
||||||
final NetworkStats tetherStatsHardware = new NetworkStats(getElapsedRealtime(), 1)
|
|
||||||
.insertEntry(TEST_IFACE, 512L, 4L, 128L, 1L);
|
|
||||||
|
|
||||||
// Traffic for UID_RED.
|
// Traffic for UID_RED.
|
||||||
final NetworkStats uidStats = new NetworkStats(getElapsedRealtime(), 1)
|
final NetworkStats uidStats = new NetworkStats(getElapsedRealtime(), 1)
|
||||||
.insertEntry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, 128L, 2L, 128L, 2L, 0L);
|
.insertEntry(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, 128L, 2L, 128L, 2L, 0L);
|
||||||
// All tethering traffic, both hardware and software.
|
// All software tethering traffic.
|
||||||
final NetworkStats tetherStats = new NetworkStats(getElapsedRealtime(), 1)
|
final NetworkStats tetherStats = new NetworkStats(getElapsedRealtime(), 1)
|
||||||
.insertEntry(TEST_IFACE, UID_TETHERING, SET_DEFAULT, TAG_NONE, 1920L, 14L, 384L, 2L,
|
.insertEntry(TEST_IFACE, UID_TETHERING, SET_DEFAULT, TAG_NONE, 1920L, 14L, 384L, 2L,
|
||||||
0L);
|
0L);
|
||||||
|
|
||||||
expectNetworkStatsSummary(ifaceStats, tetherStatsHardware);
|
expectNetworkStatsSummary(ifaceStats);
|
||||||
expectNetworkStatsUidDetail(uidStats, tetherStats);
|
expectNetworkStatsUidDetail(uidStats, tetherStats);
|
||||||
forcePollAndWaitForIdle();
|
forcePollAndWaitForIdle();
|
||||||
|
|
||||||
@@ -1362,12 +1359,6 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void expectNetworkStatsSummary(NetworkStats summary) throws Exception {
|
private void expectNetworkStatsSummary(NetworkStats summary) throws Exception {
|
||||||
expectNetworkStatsSummary(summary, new NetworkStats(0L, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void expectNetworkStatsSummary(NetworkStats summary, NetworkStats tetherStats)
|
|
||||||
throws Exception {
|
|
||||||
expectNetworkStatsTethering(STATS_PER_IFACE, tetherStats);
|
|
||||||
expectNetworkStatsSummaryDev(summary.clone());
|
expectNetworkStatsSummaryDev(summary.clone());
|
||||||
expectNetworkStatsSummaryXt(summary.clone());
|
expectNetworkStatsSummaryXt(summary.clone());
|
||||||
}
|
}
|
||||||
@@ -1380,11 +1371,6 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
|
|||||||
when(mStatsFactory.readNetworkStatsSummaryXt()).thenReturn(summary);
|
when(mStatsFactory.readNetworkStatsSummaryXt()).thenReturn(summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void expectNetworkStatsTethering(int how, NetworkStats stats)
|
|
||||||
throws Exception {
|
|
||||||
when(mNetManager.getNetworkStatsTethering(how)).thenReturn(stats);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void expectNetworkStatsUidDetail(NetworkStats detail) throws Exception {
|
private void expectNetworkStatsUidDetail(NetworkStats detail) throws Exception {
|
||||||
expectNetworkStatsUidDetail(detail, new NetworkStats(0L, 0));
|
expectNetworkStatsUidDetail(detail, new NetworkStats(0L, 0));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user