默认主卡数据网络:
final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
subscriptionManager.setDefaultDataSubId(subId);
ServiceManager.getService("isub")
/**
* SubscriptionController to provide an inter-process communication to
* access Sms in Icc.
*
* Any setters which take subId, slotId or phoneId as a parameter will throw an exception if the
* parameter equals the corresponding INVALID_XXX_ID or DEFAULT_XXX_ID.
*
* All getters will lookup the corresponding default if the parameter is DEFAULT_XXX_ID. Ie calling
* getPhoneId(DEFAULT_SUB_ID) will return the same as getPhoneId(getDefaultSubId()).
*
* Finally, any getters which perform the mapping between subscriptions, slots and phones will
* return the corresponding INVALID_XXX_ID if the parameter is INVALID_XXX_ID. All other getters
* will fail and return the appropriate error value. Ie calling getSlotId(INVALID_SUBSCRIPTION_ID)
* will return INVALID_SLOT_ID and calling getSubInfoForSubscriber(INVALID_SUBSCRIPTION_ID)
* will return null.
*
*/
public class SubscriptionController extends ISub.Stub {
DcTracker.java
public void update() {
log("update sub = " + mPhone.getSubId());
log("update(): Active DDS, register for all events now!");
onUpdateIcc();
mDataEnabledSettings.setUserDataEnabled(getDataEnabled());
mAutoAttachOnCreation.set(false);
((GsmCdmaPhone)mPhone).updateCurrentCarrierInProvider();
}
打开数据网络:
mTelephonyManager.setDataEnabled(mSubId, enabled);
Context.TELEPHONY_SERVICE
/**
* Implementation of the ITelephony interface.
*/
public class PhoneInterfaceManager extends ITelephony.Stub {}
GsmCdmaPhone.java
@Override
public void setDataEnabled(boolean enable) {
mDcTracker.setDataEnabled(enable);
}
DcTracker.java
onTrySetupData(Phone.REASON_DATA_ENABLED);
} else {
onCleanUpAllConnections(Phone.REASON_DATA_SPECIFIC_DISABLED);
}
}
}
}
private void setupDataOnConnectableApns(String reason, RetryFailures retryFailures) {
if (VDBG) log("setupDataOnConnectableApns: " + reason);
if (DBG && !VDBG) {
StringBuilder sb = new StringBuilder(120);
for (ApnContext apnContext : mPrioritySortedApnContexts) {
sb.append(apnContext.getApnType());
sb.append(":[state=");
sb.append(apnContext.getState());
sb.append(",enabled=");
sb.append(apnContext.isEnabled());
sb.append("] ");
}
log("setupDataOnConnectableApns: " + reason + " " + sb);
}
for (ApnContext apnContext : mPrioritySortedApnContexts) {
ArrayList<ApnSetting> waitingApns = null;
if (VDBG) log("setupDataOnConnectableApns: apnContext " + apnContext);
if (apnContext.getState() == DctConstants.State.FAILED
|| apnContext.getState() == DctConstants.State.SCANNING) {
if (retryFailures == RetryFailures.ALWAYS) {
apnContext.releaseDataConnection(reason);
} else if (apnContext.isConcurrentVoiceAndDataAllowed() == false &&
mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) {
// RetryFailures.ONLY_ON_CHANGE - check if voice concurrency has changed
apnContext.releaseDataConnection(reason);
} else {
// RetryFailures.ONLY_ON_CHANGE - check if the apns have changed
int radioTech = mPhone.getServiceState().getRilDataRadioTechnology();
ArrayList<ApnSetting> originalApns = apnContext.getWaitingApns();
if (originalApns != null && originalApns.isEmpty() == false) {
waitingApns = buildWaitingApns(apnContext.getApnType(), radioTech);
if (originalApns.size() != waitingApns.size() ||
originalApns.containsAll(waitingApns) == false) {
apnContext.releaseDataConnection(reason);
} else {
continue;
}
} else {
continue;
}
}
}
if (apnContext.isConnectable()) {
log("isConnectable() call trySetupData");
apnContext.setReason(reason);
trySetupData(apnContext, waitingApns);
}
}
}
1、 SubscriptionController:setDefaultSubId
设置数据库MULTI_SIM_DATA_CALL_SUBSCRIPTION
broadcastDefaultDataSubIdChanged(subId);( ITelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);)
2、 SubscriptionMonitor.java
mContext.registerReceiver(mDefaultDataSubscriptionChangedReceiver,
new IntentFilter(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED));
registerForDefaultDataSubscriptionChanged
3、 TelephonyNetworkFactory.java
mSubscriptionMonitor.registerForDefaultDataSubscriptionChanged(mPhoneId, mInternalHandler,
EVENT_DEFAULT_SUBSCRIPTION_CHANGED, null);
onDefaultChange
applyRequests
mDcTracker.requestNetwork
4、 DcTracker.java
requestNetwork
onEnableApn