[Provider Model] Add new API to detect
1. current connection is mobile data - remove the SubscriptionsPreferenceController#activeNetworkIsCellular() and move into MobileNetworkUtils 2. isProviderModel API - Add it in Util for Provider Model 3. isWiFiCallingEnabled - remove WifiCallingPreferenceController#isWifiCallingEnabled() and move into MobileNetworkUtils 4. Add nes test case for MobileNetworkUtils Bug: 171873895 Test: atest -c MobileNetworkUtilsTest Change-Id: I4bfdf0537fe07d064d6c0ba4a2c44b4a4f158d91
This commit is contained in:
@@ -24,9 +24,6 @@ import static com.android.settings.network.telephony.MobileNetworkUtils.NO_CELL_
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.SignalStrength;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
@@ -71,7 +68,6 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
private String mPreferenceGroupKey;
|
||||
private PreferenceGroup mPreferenceGroup;
|
||||
private SubscriptionManager mManager;
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
private SubscriptionsChangeListener mSubscriptionsListener;
|
||||
private MobileDataEnabledListener mDataEnabledListener;
|
||||
private DataConnectivityListener mConnectivityListener;
|
||||
@@ -112,7 +108,6 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
mPreferenceGroupKey = preferenceGroupKey;
|
||||
mStartOrder = startOrder;
|
||||
mManager = context.getSystemService(SubscriptionManager.class);
|
||||
mConnectivityManager = mContext.getSystemService(ConnectivityManager.class);
|
||||
mSubscriptionPreferences = new ArrayMap<>();
|
||||
mSubscriptionsListener = new SubscriptionsChangeListener(context, this);
|
||||
mDataEnabledListener = new MobileDataEnabledListener(context, this);
|
||||
@@ -229,19 +224,6 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
NO_CELL_DATA_TYPE_ICON, cutOut);
|
||||
}
|
||||
|
||||
private boolean activeNetworkIsCellular() {
|
||||
final Network activeNetwork = mConnectivityManager.getActiveNetwork();
|
||||
if (activeNetwork == null) {
|
||||
return false;
|
||||
}
|
||||
final NetworkCapabilities networkCapabilities = mConnectivityManager.getNetworkCapabilities(
|
||||
activeNetwork);
|
||||
if (networkCapabilities == null) {
|
||||
return false;
|
||||
}
|
||||
return networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR);
|
||||
}
|
||||
|
||||
/**
|
||||
* The summary can have either 1 or 2 lines depending on which services (calls, SMS, data) this
|
||||
* subscription is the default for.
|
||||
@@ -271,7 +253,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
final TelephonyManager telMgrForSub = mContext.getSystemService(
|
||||
TelephonyManager.class).createForSubscriptionId(subId);
|
||||
final boolean dataEnabled = telMgrForSub.isDataEnabled();
|
||||
if (dataEnabled && activeNetworkIsCellular()) {
|
||||
if (dataEnabled && MobileNetworkUtils.activeNetworkIsCellular(mContext)) {
|
||||
line2 = mContext.getString(R.string.mobile_data_active);
|
||||
} else if (!dataEnabled) {
|
||||
line2 = mContext.getString(R.string.mobile_data_off);
|
||||
|
Reference in New Issue
Block a user