[Provider Model] Implement the carrner network selection settings
- Add WifiPickerTrackerHelper to reuse the library
- User taps on carrier network preference
- Calls MergedCarrierEntry#connect()
- User toggles mobile data On/Off
- Calls MergedCarrierEntry#setEnabled(true/false)
Bug: 175761096
Test:
- Manual Test
- atest NetworkMobileProviderControllerTest \
SubscriptionsPreferenceControllerTest \
WifiPickerTrackerHelperTest
Change-Id: Ia311b10ca7a44a536556c1889ee65743af379822
This commit is contained in:
@@ -28,6 +28,7 @@ import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.wifi.WifiPickerTrackerHelper;
|
||||
|
||||
|
||||
/**
|
||||
@@ -50,6 +51,8 @@ public class MobileDataDialogFragment extends InstrumentedDialogFragment impleme
|
||||
private int mType;
|
||||
private int mSubId;
|
||||
|
||||
private WifiPickerTrackerHelper mWifiPickerTrackerHelper;
|
||||
|
||||
public static MobileDataDialogFragment newInstance(int type, int subId) {
|
||||
final MobileDataDialogFragment dialogFragment = new MobileDataDialogFragment();
|
||||
|
||||
@@ -65,6 +68,8 @@ public class MobileDataDialogFragment extends InstrumentedDialogFragment impleme
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mSubscriptionManager = getContext().getSystemService(SubscriptionManager.class);
|
||||
mWifiPickerTrackerHelper = new WifiPickerTrackerHelper(getSettingsLifecycle(), getContext(),
|
||||
null /* WifiPickerTrackerCallback */);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,11 +129,17 @@ public class MobileDataDialogFragment extends InstrumentedDialogFragment impleme
|
||||
case TYPE_DISABLE_DIALOG:
|
||||
MobileNetworkUtils.setMobileDataEnabled(getContext(), mSubId, false /* enabled */,
|
||||
false /* disableOtherSubscriptions */);
|
||||
if (mWifiPickerTrackerHelper != null) {
|
||||
mWifiPickerTrackerHelper.setCarrierNetworkEnabled(false);
|
||||
}
|
||||
break;
|
||||
case TYPE_MULTI_SIM_DIALOG:
|
||||
mSubscriptionManager.setDefaultDataSubId(mSubId);
|
||||
MobileNetworkUtils.setMobileDataEnabled(getContext(), mSubId, true /* enabled */,
|
||||
true /* disableOtherSubscriptions */);
|
||||
if (mWifiPickerTrackerHelper != null) {
|
||||
mWifiPickerTrackerHelper.setCarrierNetworkEnabled(true);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("unknown type " + mType);
|
||||
|
||||
Reference in New Issue
Block a user