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

Commit b9df1109 authored by Erik Kline's avatar Erik Kline
Browse files

Add constructor with more inputs for dependency injection.

Bug: 26991160
Bug: 27406552
Change-Id: If4a0a2f1afb1da4ad59df9eb31c540047c84659b
parent 4aeafd8f
Loading
Loading
Loading
Loading
+10 −22
Original line number Diff line number Diff line
@@ -241,15 +241,22 @@ public class IpManager extends StateMachine {

    public IpManager(Context context, String ifName, Callback callback)
                throws IllegalArgumentException {
        this(context, ifName, callback, INetworkManagementService.Stub.asInterface(
                ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE)));
    }

    /**
     * An expanded constructor, useful for dependency injection.
     */
    public IpManager(Context context, String ifName, Callback callback,
            INetworkManagementService nwService) throws IllegalArgumentException {
        super(IpManager.class.getSimpleName() + "." + ifName);
        mTag = getName();

        mContext = context;
        mInterfaceName = ifName;
        mCallback = callback;

        mNwService = INetworkManagementService.Stub.asInterface(
                ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
        mNwService = nwService;

        mNetlinkTracker = new NetlinkTracker(
                mInterfaceName,
@@ -277,25 +284,6 @@ public class IpManager extends StateMachine {
        super.start();
    }

    /**
     * A special constructor for use in testing that bypasses some of the more
     * complicated setup bits.
     *
     * TODO: Figure out how to delete this yet preserve testability.
     */
    @VisibleForTesting
    protected IpManager(String ifName, Callback callback) {
        super(IpManager.class.getSimpleName() + ".test-" + ifName);
        mTag = getName();

        mInterfaceName = ifName;
        mCallback = callback;

        mContext = null;
        mNwService = null;
        mNetlinkTracker = null;
    }

    @Override
    protected void onQuitting() {
        mCallback.onQuit();