Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e818f1b authored by Christopher R. Palmer's avatar Christopher R. Palmer Committed by Steve Kondik
Browse files

base: nat464X: Only update ipv4 pseudo-interface when it's connected

On some devices, the network link state may go up even though there
isn't going to be an active attempt to connect to the network
due to other networks taking precedence.

Currently, when this happens the network link is forced to attempt to
connect due to notification sent to the ConnectivityService.

Rather, let's wait until there is definitely an IP address and then
notify it at that time.

This solves a bad battery drain that occurs sometimes on victara
when connected to WiFi due to the mobile data network going through
constant connect/disconnect cycles.

Change-Id: Iee390f948109b3412ec86d1b3c5fbc53a4859b7b
parent f5e781dc
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -239,16 +239,12 @@ public class Nat464Xlat extends BaseNetworkObserver {
    }

    @Override
    public void interfaceLinkStateChanged(String iface, boolean up) {
    public void addressUpdated(String iface, LinkAddress clatAddress) {
        // Called by the InterfaceObserver on its own thread, so can race with stop().
        if (isStarted() && up && mIface.equals(iface)) {
        if (isStarted() && mIface.equals(iface) && clatAddress != null) {
            Slog.i(TAG, "interface " + iface + " is up, mIsRunning " + mIsRunning + "->true");

            if (!mIsRunning) {
                LinkAddress clatAddress = getLinkAddress(iface);
                if (clatAddress == null) {
                    return;
                }
                mIsRunning = true;
                maybeSetIpv6NdOffload(mBaseIface, false);
                LinkProperties lp = new LinkProperties(mNetwork.linkProperties);