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

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

Add constructor with more inputs for dependency injection.

am: b9df1109

* commit 'b9df1109':
  Add constructor with more inputs for dependency injection.
parents 6430b154 b9df1109
Loading
Loading
Loading
Loading
+10 −22
Original line number Original line Diff line number Diff line
@@ -241,15 +241,22 @@ public class IpManager extends StateMachine {


    public IpManager(Context context, String ifName, Callback callback)
    public IpManager(Context context, String ifName, Callback callback)
                throws IllegalArgumentException {
                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);
        super(IpManager.class.getSimpleName() + "." + ifName);
        mTag = getName();
        mTag = getName();


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

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


        mNetlinkTracker = new NetlinkTracker(
        mNetlinkTracker = new NetlinkTracker(
                mInterfaceName,
                mInterfaceName,
@@ -277,25 +284,6 @@ public class IpManager extends StateMachine {
        super.start();
        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
    @Override
    protected void onQuitting() {
    protected void onQuitting() {
        mCallback.onQuit();
        mCallback.onQuit();