Search in sources :

Example 11 with ProvisioningChange

use of android.net.LinkProperties.ProvisioningChange in project android_frameworks_base by crdroidandroid.

the class IpManager method compareProvisioning.

// TODO: Investigate folding all this into the existing static function
// LinkProperties.compareProvisioning() or some other single function that
// takes two LinkProperties objects and returns a ProvisioningChange
// object that is a correct and complete assessment of what changed, taking
// account of the asymmetries described in the comments in this function.
// Then switch to using it everywhere (IpReachabilityMonitor, etc.).
private ProvisioningChange compareProvisioning(LinkProperties oldLp, LinkProperties newLp) {
    ProvisioningChange delta;
    final boolean wasProvisioned = isProvisioned(oldLp);
    final boolean isProvisioned = isProvisioned(newLp);
    if (!wasProvisioned && isProvisioned) {
        delta = ProvisioningChange.GAINED_PROVISIONING;
    } else if (wasProvisioned && isProvisioned) {
        delta = ProvisioningChange.STILL_PROVISIONED;
    } else if (!wasProvisioned && !isProvisioned) {
        delta = ProvisioningChange.STILL_NOT_PROVISIONED;
    } else {
        // (wasProvisioned && !isProvisioned)
        //
        // Note that this is true even if we lose a configuration element
        // (e.g., a default gateway) that would not be required to advance
        // into provisioned state. This is intended: if we have a default
        // router and we lose it, that's a sure sign of a problem, but if
        // we connect to a network with no IPv4 DNS servers, we consider
        // that to be a network without DNS servers and connect anyway.
        //
        // See the comment below.
        delta = ProvisioningChange.LOST_PROVISIONING;
    }
    final boolean lostIPv6 = oldLp.isIPv6Provisioned() && !newLp.isIPv6Provisioned();
    final boolean lostIPv4Address = oldLp.hasIPv4Address() && !newLp.hasIPv4Address();
    final boolean lostIPv6Router = oldLp.hasIPv6DefaultRoute() && !newLp.hasIPv6DefaultRoute();
    // If bad wifi avoidance is disabled, then ignore IPv6 loss of
    // provisioning. Otherwise, when a hotspot that loses Internet
    // access sends out a 0-lifetime RA to its clients, the clients
    // will disconnect and then reconnect, avoiding the bad hotspot,
    // instead of getting stuck on the bad hotspot. http://b/31827713 .
    //
    // This is incorrect because if the hotspot then regains Internet
    // access with a different prefix, TCP connections on the
    // deprecated addresses will remain stuck.
    //
    // Note that we can still be disconnected by IpReachabilityMonitor
    // if the IPv6 default gateway (but not the IPv6 DNS servers; see
    // accompanying code in IpReachabilityMonitor) is unreachable.
    final boolean ignoreIPv6ProvisioningLoss = !mAvoidBadWifiTracker.currentValue();
    // provisioning here too.
    if (lostIPv4Address || (lostIPv6 && !ignoreIPv6ProvisioningLoss)) {
        delta = ProvisioningChange.LOST_PROVISIONING;
    }
    // to be a loss of provisioning. See b/27962810.
    if (oldLp.hasGlobalIPv6Address() && (lostIPv6Router && !ignoreIPv6ProvisioningLoss)) {
        delta = ProvisioningChange.LOST_PROVISIONING;
    }
    return delta;
}
Also used : ProvisioningChange(android.net.LinkProperties.ProvisioningChange)

Example 12 with ProvisioningChange

use of android.net.LinkProperties.ProvisioningChange in project android_frameworks_base by crdroidandroid.

the class IpReachabilityMonitor method handleNeighborLost.

private void handleNeighborLost(String msg) {
    InetAddress ip = null;
    final ProvisioningChange delta;
    synchronized (mLock) {
        LinkProperties whatIfLp = new LinkProperties(mLinkProperties);
        for (Map.Entry<InetAddress, Short> entry : mIpWatchList.entrySet()) {
            if (entry.getValue() != StructNdMsg.NUD_FAILED) {
                continue;
            }
            ip = entry.getKey();
            for (RouteInfo route : mLinkProperties.getRoutes()) {
                if (ip.equals(route.getGateway())) {
                    whatIfLp.removeRoute(route);
                }
            }
            if (avoidingBadLinks() || !(ip instanceof Inet6Address)) {
                // We should do this unconditionally, but alas we cannot: b/31827713.
                whatIfLp.removeDnsServer(ip);
            }
        }
        delta = LinkProperties.compareProvisioning(mLinkProperties, whatIfLp);
    }
    if (delta == ProvisioningChange.LOST_PROVISIONING) {
        final String logMsg = "FAILURE: LOST_PROVISIONING, " + msg;
        Log.w(TAG, logMsg);
        if (mCallback != null) {
            // TODO: remove |ip| when the callback signature no longer has
            // an InetAddress argument.
            mCallback.notifyLost(ip, logMsg);
        }
    }
    logNudFailed(delta);
}
Also used : Inet6Address(java.net.Inet6Address) ProvisioningChange(android.net.LinkProperties.ProvisioningChange) RouteInfo(android.net.RouteInfo) InetAddress(java.net.InetAddress) LinkProperties(android.net.LinkProperties) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with ProvisioningChange

use of android.net.LinkProperties.ProvisioningChange in project android_frameworks_base by crdroidandroid.

the class IpManager method handleProvisioningFailure.

private void handleProvisioningFailure() {
    final LinkProperties newLp = assembleLinkProperties();
    ProvisioningChange delta = setLinkProperties(newLp);
    // Regardless: GAME OVER.
    if (delta == ProvisioningChange.STILL_NOT_PROVISIONED) {
        delta = ProvisioningChange.LOST_PROVISIONING;
    }
    dispatchCallback(delta, newLp);
    if (delta == ProvisioningChange.LOST_PROVISIONING) {
        transitionTo(mStoppingState);
    }
}
Also used : ProvisioningChange(android.net.LinkProperties.ProvisioningChange) LinkProperties(android.net.LinkProperties)

Example 14 with ProvisioningChange

use of android.net.LinkProperties.ProvisioningChange in project platform_frameworks_base by android.

the class IpManager method handleIPv4Success.

private void handleIPv4Success(DhcpResults dhcpResults) {
    mDhcpResults = new DhcpResults(dhcpResults);
    final LinkProperties newLp = assembleLinkProperties();
    final ProvisioningChange delta = setLinkProperties(newLp);
    if (VDBG) {
        Log.d(mTag, "onNewDhcpResults(" + Objects.toString(dhcpResults) + ")");
    }
    mCallback.onNewDhcpResults(dhcpResults);
    dispatchCallback(delta, newLp);
}
Also used : DhcpResults(android.net.DhcpResults) ProvisioningChange(android.net.LinkProperties.ProvisioningChange) LinkProperties(android.net.LinkProperties)

Example 15 with ProvisioningChange

use of android.net.LinkProperties.ProvisioningChange in project platform_frameworks_base by android.

the class IpManager method handleLinkPropertiesUpdate.

// Returns false if we have lost provisioning, true otherwise.
private boolean handleLinkPropertiesUpdate(boolean sendCallbacks) {
    final LinkProperties newLp = assembleLinkProperties();
    if (linkPropertiesUnchanged(newLp)) {
        return true;
    }
    final ProvisioningChange delta = setLinkProperties(newLp);
    if (sendCallbacks) {
        dispatchCallback(delta, newLp);
    }
    return (delta != ProvisioningChange.LOST_PROVISIONING);
}
Also used : ProvisioningChange(android.net.LinkProperties.ProvisioningChange) LinkProperties(android.net.LinkProperties)

Aggregations

ProvisioningChange (android.net.LinkProperties.ProvisioningChange)24 LinkProperties (android.net.LinkProperties)20 DhcpResults (android.net.DhcpResults)4 RouteInfo (android.net.RouteInfo)4 Inet6Address (java.net.Inet6Address)4 InetAddress (java.net.InetAddress)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4