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

Commit 24f7d5e6 authored by Erik Kline's avatar Erik Kline Committed by android-build-merger
Browse files

Add 464xlat notification callback

am: 8d6edc32

* commit '8d6edc32':
  Add 464xlat notification callback
parents 1856df51 8d6edc32
Loading
Loading
Loading
Loading
+29 −4
Original line number Diff line number Diff line
@@ -66,9 +66,6 @@ public class IpManager extends StateMachine {
    private static final boolean DBG = true;
    private static final boolean VDBG = false;

    private static final boolean NO_CALLBACKS = false;
    private static final boolean SEND_CALLBACKS = true;

    // For message logging.
    private static final Class[] sMessageClasses = { IpManager.class, DhcpClient.class };
    private static final SparseArray<String> sWhatToString =
@@ -98,6 +95,10 @@ public class IpManager extends StateMachine {
        public void onProvisioningSuccess(LinkProperties newLp) {}
        public void onProvisioningFailure(LinkProperties newLp) {}

        // This is called whenever 464xlat is being enabled or disabled (i.e.
        // started or stopped).
        public void on464XlatChange(boolean enabled) {}

        // Invoked on LinkProperties changes.
        public void onLinkPropertiesChange(LinkProperties newLp) {}

@@ -207,6 +208,13 @@ public class IpManager extends StateMachine {

    private static final int MAX_LOG_RECORDS = 1000;

    private static final boolean NO_CALLBACKS = false;
    private static final boolean SEND_CALLBACKS = true;

    // This must match the interface prefix in clatd.c.
    // TODO: Revert this hack once IpManager and Nat464Xlat work in concert.
    private static final String CLAT_PREFIX = "v4-";

    private final Object mLock = new Object();
    private final State mStoppedState = new StoppedState();
    private final State mStoppingState = new StoppingState();
@@ -215,6 +223,7 @@ public class IpManager extends StateMachine {
    private final String mTag;
    private final Context mContext;
    private final String mInterfaceName;
    private final String mClatInterfaceName;
    @VisibleForTesting
    protected final Callback mCallback;
    private final INetworkManagementService mNwService;
@@ -255,6 +264,7 @@ public class IpManager extends StateMachine {

        mContext = context;
        mInterfaceName = ifName;
        mClatInterfaceName = CLAT_PREFIX + ifName;
        mCallback = callback;
        mNwService = nwService;

@@ -265,7 +275,22 @@ public class IpManager extends StateMachine {
                    public void update() {
                        sendMessage(EVENT_NETLINK_LINKPROPERTIES_CHANGED);
                    }
                });
                }) {
            @Override
            public void interfaceAdded(String iface) {
                if (mClatInterfaceName.equals(iface)) {
                    mCallback.on464XlatChange(true);
                }
            }

            @Override
            public void interfaceRemoved(String iface) {
                if (mClatInterfaceName.equals(iface)) {
                    mCallback.on464XlatChange(false);
                }
            }
        };

        try {
            mNwService.registerObserver(mNetlinkTracker);
        } catch (RemoteException e) {