[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:
@@ -32,6 +32,7 @@ import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.MobileDataContentObserver;
|
||||
import com.android.settings.wifi.WifiPickerTrackerHelper;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
@@ -54,6 +55,8 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
|
||||
@VisibleForTesting
|
||||
boolean mNeedDialog;
|
||||
|
||||
private WifiPickerTrackerHelper mWifiPickerTrackerHelper;
|
||||
|
||||
public MobileDataPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
||||
@@ -107,6 +110,9 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
|
||||
if (!mNeedDialog) {
|
||||
// Update data directly if we don't need dialog
|
||||
MobileNetworkUtils.setMobileDataEnabled(mContext, mSubId, isChecked, false);
|
||||
if (mWifiPickerTrackerHelper != null) {
|
||||
mWifiPickerTrackerHelper.setCarrierNetworkEnabled(isChecked);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -149,6 +155,10 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
|
||||
.createForSubscriptionId(mSubId);
|
||||
}
|
||||
|
||||
public void setWifiPickerTrackerHelper(WifiPickerTrackerHelper helper) {
|
||||
mWifiPickerTrackerHelper = helper;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isDialogNeeded() {
|
||||
final boolean enableData = !isChecked();
|
||||
|
Reference in New Issue
Block a user