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

Commit 6ec93726 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Migrate to IpClient and eschew MultinetworkPolicyTracker"

parents 2ae9a725 feb82442
Loading
Loading
Loading
Loading
+15 −14
Original line number Diff line number Diff line
@@ -25,8 +25,8 @@ import android.net.NetworkCapabilities;
import android.net.NetworkFactory;
import android.net.NetworkInfo;
import android.net.NetworkInfo.DetailedState;
import android.net.ip.IpManager;
import android.net.ip.IpManager.WaitForProvisioningCallback;
import android.net.ip.IpClient;
import android.net.ip.IpClient.WaitForProvisioningCallback;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Slog;
@@ -49,7 +49,7 @@ public class BluetoothTetheringNetworkFactory extends NetworkFactory {

    // All accesses to these must be synchronized(this).
    private final NetworkInfo mNetworkInfo;
    private IpManager mIpManager;
    private IpClient mIpClient;
    private String mInterfaceName;
    private NetworkAgent mNetworkAgent;

@@ -65,10 +65,10 @@ public class BluetoothTetheringNetworkFactory extends NetworkFactory {
        setCapabilityFilter(mNetworkCapabilities);
    }

    private void stopIpManagerLocked() {
        if (mIpManager != null) {
            mIpManager.shutdown();
            mIpManager = null;
    private void stopIpClientLocked() {
        if (mIpClient != null) {
            mIpClient.shutdown();
            mIpClient = null;
        }
    }

@@ -78,13 +78,13 @@ public class BluetoothTetheringNetworkFactory extends NetworkFactory {
    @Override
    protected void startNetwork() {
        // TODO: Figure out how to replace this thread with simple invocations
        // of IpManager. This will likely necessitate a rethink about
        // of IpClient. This will likely necessitate a rethink about
        // NetworkAgent, NetworkInfo, and associated instance lifetimes.
        Thread ipProvisioningThread = new Thread(new Runnable() {
            @Override
            public void run() {
                LinkProperties linkProperties;
                final WaitForProvisioningCallback ipmCallback = new WaitForProvisioningCallback() {
                final WaitForProvisioningCallback ipcCallback = new WaitForProvisioningCallback() {
                    @Override
                    public void onLinkPropertiesChange(LinkProperties newLp) {
                        synchronized (BluetoothTetheringNetworkFactory.this) {
@@ -102,18 +102,19 @@ public class BluetoothTetheringNetworkFactory extends NetworkFactory {
                    }
                    log("ipProvisioningThread(+" + mInterfaceName + "): " + "mNetworkInfo="
                            + mNetworkInfo);
                    mIpManager = new IpManager(mContext, mInterfaceName, ipmCallback);
                    mIpManager.startProvisioning(mIpManager.buildProvisioningConfiguration()
                    mIpClient = new IpClient(mContext, mInterfaceName, ipcCallback);
                    mIpClient.startProvisioning(mIpClient.buildProvisioningConfiguration()
                            .withoutMultinetworkPolicyTracker()
                            .withoutIpReachabilityMonitor()
                            .build());
                    mNetworkInfo.setDetailedState(DetailedState.OBTAINING_IPADDR, null, null);
                }

                linkProperties = ipmCallback.waitForProvisioning();
                linkProperties = ipcCallback.waitForProvisioning();
                if (linkProperties == null) {
                    Slog.e(TAG, "IP provisioning error.");
                    synchronized (BluetoothTetheringNetworkFactory.this) {
                        stopIpManagerLocked();
                        stopIpClientLocked();
                        setScoreFilter(-1);
                    }
                    return;
@@ -149,7 +150,7 @@ public class BluetoothTetheringNetworkFactory extends NetworkFactory {

    // Called by the NetworkFactory, NetworkAgent or PanService to tear down network.
    private synchronized void onCancelRequest() {
        stopIpManagerLocked();
        stopIpClientLocked();
        mInterfaceName = "";

        mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null, null);