[Provider Model] Implement the carrner network selection

- Add primaryAction for connecting carrier network

- User toggles carrier network On/Off
  - Calls MergedCarrierEntry#setEnabled(true/false)

- User taps on carrier network
  - Calls MergedCarrierEntry#connect()

Bug: 175761096
Test:
- Manual Test
- atest ProviderModelSliceTest
- atest ProviderModelSliceHelperTest
- make RunSettingsRoboTests ROBOTEST_FILTER=WifiScanWorkerTest

Change-Id: I07cb6c142a2f4e9cbdbab1f77afdc367728b4e3f
This commit is contained in:
Weng Su
2020-12-27 17:37:41 +00:00
parent 2133856853
commit 74b18587fb
5 changed files with 95 additions and 8 deletions

View File

@@ -165,16 +165,28 @@ public class ProviderModelSlice extends WifiSlice {
if (subscriptionManager == null) {
return;
}
final boolean newState = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
mHelper.isMobileDataEnabled());
final int defaultSubId = subscriptionManager.getDefaultDataSubscriptionId();
log("defaultSubId:" + defaultSubId);
if (!SubscriptionManager.isUsableSubscriptionId(defaultSubId)) {
return; // No subscription - do nothing.
}
boolean requestConnectCarrier = !intent.hasExtra(EXTRA_TOGGLE_STATE);
// Enable the mobile data always if the user requests to connect to the carrier network.
boolean newState = requestConnectCarrier ? true
: intent.getBooleanExtra(EXTRA_TOGGLE_STATE, mHelper.isMobileDataEnabled());
MobileNetworkUtils.setMobileDataEnabled(mContext, defaultSubId, newState,
false /* disableOtherSubscriptions */);
final NetworkProviderWorker worker = getWorker();
if (worker == null) {
return;
}
if (requestConnectCarrier) {
worker.connectCarrierNetwork();
} else {
worker.setCarrierNetworkEnabled(newState);
}
}
@Override