Merge "[Provider Model] Implement the carrner network selection"
This commit is contained in:
@@ -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
|
||||
|
@@ -131,14 +131,16 @@ public class ProviderModelSliceHelper {
|
||||
e.printStackTrace();
|
||||
}
|
||||
final IconCompat levelIcon = Utils.createIconWithDrawable(drawable);
|
||||
final PendingIntent toggleAction = mSliceable.getBroadcastIntent(mContext);
|
||||
final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction,
|
||||
final PendingIntent rowIntent = mSliceable.getBroadcastIntent(mContext);
|
||||
final SliceAction primaryAction = SliceAction.create(rowIntent,
|
||||
levelIcon, ListBuilder.ICON_IMAGE, title);
|
||||
final SliceAction toggleAction = SliceAction.createToggle(rowIntent,
|
||||
"mobile_toggle" /* actionTitle */, isMobileDataEnabled());
|
||||
final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder()
|
||||
.setTitle(title)
|
||||
.setTitleItem(levelIcon, ListBuilder.ICON_IMAGE)
|
||||
.addEndItem(toggleSliceAction)
|
||||
.setPrimaryAction(toggleSliceAction)
|
||||
.addEndItem(toggleAction)
|
||||
.setPrimaryAction(primaryAction)
|
||||
.setSubtitle(summary);
|
||||
return rowBuilder;
|
||||
}
|
||||
|
Reference in New Issue
Block a user