Merge "[MS49] Remove NetworkStats hidden Api usages"

This commit is contained in:
Junyu Lai
2022-01-28 00:42:44 +00:00
committed by Android (Google) Code Review
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);

View File

@@ -33,9 +33,9 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.net.TrafficStats;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.DataUnit;
import android.util.SparseArray;
import androidx.test.core.app.ApplicationProvider;
@@ -62,7 +62,7 @@ public class StorageAsyncLoaderTest {
private static final String PACKAGE_NAME_1 = "com.blah.test";
private static final String PACKAGE_NAME_2 = "com.blah.test2";
private static final String PACKAGE_NAME_3 = "com.blah.test3";
private static final long DEFAULT_QUOTA = 64 * TrafficStats.MB_IN_BYTES;
private static final long DEFAULT_QUOTA = DataUnit.MEBIBYTES.toBytes(64);
@Mock
private StorageStatsSource mSource;