[MS49] Remove NetworkStats hidden Api usages

This includes:
1. Remove unused INetworkStatsService and NetworkStatsHistory.
2. Replace NetworkTemplate usages with builder.
3. Replace TrafficStats references to DataUnit.
4. Reimplement NetworkTemplate#normalize.

Test: make RunSettingsRoboTests
Bug: 204830222
Change-Id: I8efecda5df403e9ed588daecd169cb3498d213a2
This commit is contained in:
Junyu Lai
2022-01-10 12:30:16 +00:00
parent 5ff3e8dc8a
commit 25e26ea7af
12 changed files with 40 additions and 32 deletions

View File

@@ -18,7 +18,7 @@ package com.android.settings.datausage;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -438,7 +438,7 @@ public class AppDataUsageTest {
assertThat(mFragment.mTemplate.getMatchRule())
.isEqualTo(NetworkTemplate.MATCH_WIFI);
assertNull(mFragment.mTemplate.getSubscriberId());
assertTrue(mFragment.mTemplate.getSubscriberIds().isEmpty());
assertThat(mFragment.mTemplate.getNetworkId())
.isEqualTo(NetworkTemplate.WIFI_NETWORKID_ALL);
}

View File

@@ -26,10 +26,10 @@ import static org.mockito.Mockito.spy;
import android.app.usage.NetworkStatsManager;
import android.content.Context;
import android.content.Intent;
import android.net.TrafficStats;
import android.provider.Settings;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.DataUnit;
import androidx.preference.SwitchPreference;
@@ -128,7 +128,7 @@ public class DataUsagePreferenceControllerTest {
public void updateState_shouldUseIECUnit() {
final DataUsageController.DataUsageInfo usageInfo =
new DataUsageController.DataUsageInfo();
usageInfo.usageLevel = TrafficStats.MB_IN_BYTES;
usageInfo.usageLevel = DataUnit.MEBIBYTES.toBytes(1);
doReturn(usageInfo).when(mController).getDataUsageInfo(any());
mController.updateState(mPreference);