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

@@ -36,8 +36,8 @@ import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.NetworkPolicyManager;
import android.os.Bundle;
@@ -72,9 +72,9 @@ public class BillingCycleSettingsTest {
@Mock
private NetworkPolicyEditor mNetworkPolicyEditor;
@Mock
private ConnectivityManager mConnectivityManager;
@Mock
private NetworkPolicyManager mNetworkPolicyManager;
@Mock
private PackageManager mMockPackageManager;
private Context mContext;
@Mock
@@ -157,9 +157,8 @@ public class BillingCycleSettingsTest {
.onCreatePreferences(any(Bundle.class), nullable(String.class));
when(mContext.getSystemService(Context.NETWORK_POLICY_SERVICE))
.thenReturn(mNetworkPolicyManager);
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
.thenReturn(mConnectivityManager);
when(mConnectivityManager.isNetworkSupported(anyInt())).thenReturn(true);
when(mContext.getPackageManager()).thenReturn(mMockPackageManager);
when(mMockPackageManager.hasSystemFeature(any())).thenReturn(true);
final SwitchPreference preference = mock(SwitchPreference.class);
when(billingCycleSettings.findPreference(anyString())).thenReturn(preference);