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

Commit 0326f777 authored by Lorenzo Colitti's avatar Lorenzo Colitti Committed by Android (Google) Code Review
Browse files

Merge changes I9b96cdcf,Ib4b29a7f into mnc-dev

* changes:
  Remove the IPv4 address from the interface when DHCP fails.
  Make the dumpsys connectivity shorter and easier to read.
parents 56396c7f 48f9c731
Loading
Loading
Loading
Loading
+25 −18
Original line number Diff line number Diff line
@@ -543,16 +543,24 @@ public class ConnectivityService extends IConnectivityManager.Stub
        }

        public void dump(IndentingPrintWriter pw) {
            pw.println("mLegacyTypeTracker:");
            pw.increaseIndent();
            pw.print("Supported types:");
            for (int type = 0; type < mTypeLists.length; type++) {
                if (mTypeLists[type] == null) continue;
                pw.print(type + " ");
                if (mTypeLists[type] != null) pw.print(" " + type);
            }
            pw.println();
            pw.println("Current state:");
            pw.increaseIndent();
                if (mTypeLists[type].size() == 0) pw.println("none");
            for (int type = 0; type < mTypeLists.length; type++) {
                if (mTypeLists[type] == null|| mTypeLists[type].size() == 0) continue;
                for (NetworkAgentInfo nai : mTypeLists[type]) {
                    pw.println(naiToString(nai));
                    pw.println(type + " " + naiToString(nai));
                }
                pw.decreaseIndent();
            }
            pw.decreaseIndent();
            pw.decreaseIndent();
            pw.println();
        }

        // This class needs its own log method because it has a different TAG.
@@ -1750,12 +1758,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
            return;
        }

        pw.println("NetworkFactories for:");
        pw.increaseIndent();
        pw.print("NetworkFactories for:");
        for (NetworkFactoryInfo nfi : mNetworkFactoryInfos.values()) {
            pw.println(nfi.name);
            pw.print(" " + nfi.name);
        }
        pw.decreaseIndent();
        pw.println();
        pw.println();

        NetworkAgentInfo defaultNai = mNetworkForRequestId.get(mDefaultRequest.requestId);
@@ -1795,22 +1802,22 @@ public class ConnectivityService extends IConnectivityManager.Stub
        pw.println();
        pw.decreaseIndent();

        pw.println("mLegacyTypeTracker:");
        pw.increaseIndent();
        mLegacyTypeTracker.dump(pw);
        pw.decreaseIndent();
        pw.println();

        synchronized (this) {
            pw.println("NetworkTransitionWakeLock is currently " +
                    (mNetTransitionWakeLock.isHeld() ? "" : "not ") + "held.");
            pw.println("It was last requested for "+mNetTransitionWakeLockCausedBy);
            pw.print("mNetTransitionWakeLock: currently " +
                    (mNetTransitionWakeLock.isHeld() ? "" : "not ") + "held");
            if (!TextUtils.isEmpty(mNetTransitionWakeLockCausedBy)) {
                pw.println(", last requested for " + mNetTransitionWakeLockCausedBy);
            } else {
                pw.println(", last requested never");
            }
        }
        pw.println();

        mTethering.dump(fd, pw, args);

        if (mInetLog != null) {
        if (mInetLog != null && mInetLog.size() > 0) {
            pw.println();
            pw.println("Inet condition reports:");
            pw.increaseIndent();
+13 −6
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.IState;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
@@ -1684,7 +1685,9 @@ public class Tethering extends BaseNetworkObserver {
        }
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
        final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");

        if (mContext.checkCallingOrSelfPermission(
                android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
            pw.println("Permission Denial: can't dump ConnectivityService.Tether " +
@@ -1693,19 +1696,23 @@ public class Tethering extends BaseNetworkObserver {
                    return;
        }

        pw.println("Tethering:");
        pw.increaseIndent();
        pw.print("mUpstreamIfaceTypes:");
        synchronized (mPublicSync) {
            pw.println("mUpstreamIfaceTypes: ");
            for (Integer netType : mUpstreamIfaceTypes) {
                pw.println(" " + netType);
                pw.print(" " + ConnectivityManager.getNetworkTypeName(netType));
            }

            pw.println();

            pw.println("Tether state:");
            pw.increaseIndent();
            for (Object o : mIfaces.values()) {
                pw.println(" " + o);
                pw.println(o);
            }
            pw.decreaseIndent();
        }
        pw.println();
        pw.decreaseIndent();
        return;
    }
}
+25 −12
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ public class DhcpClient extends BaseDhcpStateMachine {
    private State mDhcpInitState = new DhcpInitState();
    private State mDhcpSelectingState = new DhcpSelectingState();
    private State mDhcpRequestingState = new DhcpRequestingState();
    private State mDhcpHaveAddressState = new DhcpHaveAddressState();
    private State mDhcpBoundState = new DhcpBoundState();
    private State mDhcpRenewingState = new DhcpRenewingState();
    private State mDhcpRebindingState = new DhcpRebindingState();
@@ -186,10 +187,11 @@ public class DhcpClient extends BaseDhcpStateMachine {
            addState(mWaitBeforeStartState, mDhcpState);
            addState(mDhcpSelectingState, mDhcpState);
            addState(mDhcpRequestingState, mDhcpState);
            addState(mDhcpBoundState, mDhcpState);
            addState(mWaitBeforeRenewalState, mDhcpState);
            addState(mDhcpRenewingState, mDhcpState);
            addState(mDhcpRebindingState, mDhcpState);
            addState(mDhcpHaveAddressState, mDhcpState);
                addState(mDhcpBoundState, mDhcpHaveAddressState);
                addState(mWaitBeforeRenewalState, mDhcpHaveAddressState);
                addState(mDhcpRenewingState, mDhcpHaveAddressState);
                addState(mDhcpRebindingState, mDhcpHaveAddressState);
            addState(mDhcpInitRebootState, mDhcpState);
            addState(mDhcpRebootingState, mDhcpState);

@@ -402,7 +404,7 @@ public class DhcpClient extends BaseDhcpStateMachine {
        }
    }

    private void notifyLease() {
    private void notifySuccess() {
        mController.sendMessage(DhcpStateMachine.CMD_POST_DHCP_ACTION,
                DhcpStateMachine.DHCP_SUCCESS, 0, new DhcpResults(mDhcpLease));
    }
@@ -752,21 +754,32 @@ public class DhcpClient extends BaseDhcpStateMachine {
        }
    }

    class DhcpBoundState extends LoggingState {
    class DhcpHaveAddressState extends LoggingState {
        @Override
        public void enter() {
            super.enter();
            if (setIpAddress(mDhcpLease.ipAddress)) {
                notifyLease();
                // TODO: DhcpStateMachine only supports renewing at 50% of the lease time,
                // and does not support rebinding. Fix this.
                scheduleRenew();
            } else {
            if (!setIpAddress(mDhcpLease.ipAddress)) {
                notifyFailure();
                transitionTo(mStoppedState);
            }
        }

        @Override
        public void exit() {
            setIpAddress(new LinkAddress("0.0.0.0/0"));
        }
    }

    class DhcpBoundState extends LoggingState {
        @Override
        public void enter() {
            super.enter();
            notifySuccess();
            // TODO: DhcpStateMachine only supports renewing at 50% of the lease time, and does not
            // support rebinding. Fix this.
            scheduleRenew();
        }

        @Override
        public boolean processMessage(Message message) {
            super.processMessage(message);