Replace hidden CM#isNetworkSupported() usage

It's a refactor work for connectivity mainline module. The
hidden methods access is no longer allowed, so the usage for
isNetworkSupported() should be replaced. Settings use it to
check if device support telephony, wifi or ethernet service.
There are alternative methods to check if device supports such
features. Replace as it is.

Bug: 172183305
Test: m ; make RunSettingsRoboTests
Change-Id: I8f1d11558b1be575a0777ed195abe027e838cb74
This commit is contained in:
Chiachang Wang
2021-03-16 17:03:31 +08:00
parent 8105206432
commit ffbe4e9b1e
8 changed files with 45 additions and 61 deletions

View File

@@ -25,7 +25,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.net.ConnectivityManager;
import android.os.Looper;
import android.os.UserManager;
import android.provider.Settings;
@@ -63,8 +62,6 @@ public class MobileNetworkPreferenceControllerTest {
@Mock
private UserManager mUserManager;
@Mock
private ConnectivityManager mConnectivityManager;
private PreferenceManager mPreferenceManager;
private PreferenceScreen mScreen;
@@ -82,7 +79,6 @@ public class MobileNetworkPreferenceControllerTest {
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
if (Looper.myLooper() == null) {
Looper.prepare();
}
@@ -98,8 +94,7 @@ public class MobileNetworkPreferenceControllerTest {
@Test
public void secondaryUser_prefIsNotAvailable() {
when(mUserManager.isAdminUser()).thenReturn(false);
when(mConnectivityManager.isNetworkSupported(ConnectivityManager.TYPE_MOBILE))
.thenReturn(true);
when(mTelephonyManager.isDataCapable()).thenReturn(true);
mController = new MobileNetworkPreferenceController(mContext);
assertThat(mController.isAvailable()).isFalse();
@@ -108,8 +103,7 @@ public class MobileNetworkPreferenceControllerTest {
@Test
public void wifiOnly_prefIsNotAvailable() {
when(mUserManager.isAdminUser()).thenReturn(true);
when(mConnectivityManager.isNetworkSupported(ConnectivityManager.TYPE_MOBILE))
.thenReturn(false);
when(mTelephonyManager.isDataCapable()).thenReturn(false);
mController = new MobileNetworkPreferenceController(mContext);
assertThat(mController.isAvailable()).isFalse();