* commit 'bd84f01c6ce122ab58fc7c5b687dc8bfb0fb03e6': Handle provisioning APN by turning off/on data.
This commit is contained in:
@ -566,6 +566,17 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void setInternalDataEnable(boolean enabled) {
|
||||
if (DBG) log("setInternalDataEnable: E enabled=" + enabled);
|
||||
final AsyncChannel channel = mDataConnectionTrackerAc;
|
||||
if (channel != null) {
|
||||
channel.sendMessage(DctConstants.EVENT_SET_INTERNAL_DATA_ENABLE,
|
||||
enabled ? DctConstants.ENABLED : DctConstants.DISABLED);
|
||||
}
|
||||
if (VDBG) log("setInternalDataEnable: X enabled=" + enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserDataEnable(boolean enabled) {
|
||||
if (DBG) log("setUserDataEnable: E enabled=" + enabled);
|
||||
|
@ -4069,6 +4069,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
*/
|
||||
private static final int CMP_RESULT_CODE_PROVISIONING_NETWORK = 5;
|
||||
|
||||
/**
|
||||
* The mobile network is provisioning
|
||||
*/
|
||||
private static final int CMP_RESULT_CODE_IS_PROVISIONING = 6;
|
||||
|
||||
private AtomicBoolean mIsProvisioningNetwork = new AtomicBoolean(false);
|
||||
private AtomicBoolean mIsStartingProvisioning = new AtomicBoolean(false);
|
||||
|
||||
private AtomicBoolean mIsCheckingMobileProvisioning = new AtomicBoolean(false);
|
||||
|
||||
@Override
|
||||
@ -4139,11 +4147,25 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
setProvNotificationVisible(true,
|
||||
ConnectivityManager.TYPE_MOBILE_HIPRI, ni.getExtraInfo(),
|
||||
url);
|
||||
// Mark that we've got a provisioning network and
|
||||
// Disable Mobile Data until user actually starts provisioning.
|
||||
mIsProvisioningNetwork.set(true);
|
||||
MobileDataStateTracker mdst = (MobileDataStateTracker)
|
||||
mNetTrackers[ConnectivityManager.TYPE_MOBILE];
|
||||
mdst.setInternalDataEnable(false);
|
||||
} else {
|
||||
if (DBG) log("CheckMp.onComplete: warm (no dns/tcp), no url");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CMP_RESULT_CODE_IS_PROVISIONING: {
|
||||
// FIXME: Need to know when provisioning is done. Probably we can
|
||||
// check the completion status if successful we're done if we
|
||||
// "timedout" or still connected to provisioning APN turn off data?
|
||||
if (DBG) log("CheckMp.onComplete: provisioning started");
|
||||
mIsStartingProvisioning.set(false);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
loge("CheckMp.onComplete: ignore unexpected result=" + result);
|
||||
break;
|
||||
@ -4293,6 +4315,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (mCs.mIsStartingProvisioning.get()) {
|
||||
result = CMP_RESULT_CODE_IS_PROVISIONING;
|
||||
log("isMobileOk: X is provisioning result=" + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// See if we've already determined we've got a provisioning connection,
|
||||
// if so we don't need to do anything active.
|
||||
MobileDataStateTracker mdstDefault = (MobileDataStateTracker)
|
||||
@ -4627,19 +4655,20 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
};
|
||||
|
||||
private void handleMobileProvisioningAction(String url) {
|
||||
// Notication mark notification as not visible
|
||||
// Mark notification as not visible
|
||||
setProvNotificationVisible(false, ConnectivityManager.TYPE_MOBILE_HIPRI, null, null);
|
||||
|
||||
// If provisioning network handle as a special case,
|
||||
// otherwise launch browser with the intent directly.
|
||||
NetworkInfo ni = getProvisioningNetworkInfo();
|
||||
if ((ni != null) && ni.isConnectedToProvisioningNetwork()) {
|
||||
if (DBG) log("handleMobileProvisioningAction: on provisioning network");
|
||||
if (mIsProvisioningNetwork.get()) {
|
||||
if (DBG) log("handleMobileProvisioningAction: on prov network enable then launch");
|
||||
mIsStartingProvisioning.set(true);
|
||||
MobileDataStateTracker mdst = (MobileDataStateTracker)
|
||||
mNetTrackers[ConnectivityManager.TYPE_MOBILE];
|
||||
mdst.setEnableFailFastMobileData(DctConstants.ENABLED);
|
||||
mdst.enableMobileProvisioning(url);
|
||||
} else {
|
||||
if (DBG) log("handleMobileProvisioningAction: on default network");
|
||||
if (DBG) log("handleMobileProvisioningAction: not prov network, launch browser directly");
|
||||
Intent newIntent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN,
|
||||
Intent.CATEGORY_APP_BROWSER);
|
||||
newIntent.setData(Uri.parse(url));
|
||||
|
Reference in New Issue
Block a user