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

Commit cec2c552 authored by Chiachang Wang's avatar Chiachang Wang Committed by Automerger Merge Worker
Browse files

Merge "Remove hidden connectivity method usage" am: 82628265

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1674570

Change-Id: I9bfa535f64717b36216c987c35025b52fe22c078
parents d3404b3c 82628265
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ public class ConnectivityManagerTestBase extends InstrumentationTestCase {
    private Context mContext;
    protected List<ScanResult> mLastScanResult;
    protected Object mWifiScanResultLock = new Object();
    public TetheringManager mTetheringManager;

    /* Control Wifi States */
    public WifiManager mWifiManager;
@@ -129,6 +130,7 @@ public class ConnectivityManagerTestBase extends InstrumentationTestCase {
        mCm = (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
        // Get an instance of WifiManager
        mWifiManager =(WifiManager)mContext.getSystemService(Context.WIFI_SERVICE);
        mTetheringManager = mContext.getSystemService(TetheringManager.class);

        // register a connectivity receiver for CONNECTIVITY_ACTION;
        mConnectivityReceiver = new ConnectivityReceiver();
@@ -216,13 +218,13 @@ public class ConnectivityManagerTestBase extends InstrumentationTestCase {
     */
    protected boolean waitForTetherStateChange(long timeout) {
        long startTime = SystemClock.uptimeMillis();
        String[] wifiRegexes = mCm.getTetherableWifiRegexs();
        String[] wifiRegexes = mTetheringManager.getTetherableWifiRegexs();
        while (true) {
            if ((SystemClock.uptimeMillis() - startTime) > timeout) {
                return false;
            }
            String[] active = mCm.getTetheredIfaces();
            String[] error = mCm.getTetheringErroredIfaces();
            String[] active = mTetheringManager.getTetheredIfaces();
            String[] error = mTetheringManager.getTetheringErroredIfaces();
            for (String iface: active) {
                for (String regex: wifiRegexes) {
                    if (iface.matches(regex)) {
+9 −7
Original line number Diff line number Diff line
@@ -244,17 +244,19 @@ public class WifiConfigurationHelper {

        IpConfiguration ipConfiguration = config.getIpConfiguration();
        if (jsonConfig.has("ip")) {
            StaticIpConfiguration staticIpConfig = new StaticIpConfiguration();

            InetAddress ipAddress = getInetAddress(jsonConfig.getString("ip"));
            int prefixLength = getPrefixLength(jsonConfig.getInt("prefix_length"));
            staticIpConfig.ipAddress = new LinkAddress(ipAddress, prefixLength);
            staticIpConfig.gateway = getInetAddress(jsonConfig.getString("gateway"));
            staticIpConfig.dnsServers.add(getInetAddress(jsonConfig.getString("dns1")));
            staticIpConfig.dnsServers.add(getInetAddress(jsonConfig.getString("dns2")));

            final StaticIpConfiguration.Builder builder = new StaticIpConfiguration.Builder();
            builder.setIpAddress(new LinkAddress(ipAddress, prefixLength));
            builder.setGateway(getInetAddress(jsonConfig.getString("gateway")));
            final ArrayList<InetAddress> dnsServers = new ArrayList<>();
            dnsServers.add(getInetAddress(jsonConfig.getString("dns1")));
            dnsServers.add(getInetAddress(jsonConfig.getString("dns2")));
            builder.setDnsServers(dnsServers);
            ipConfiguration.setStaticIpConfiguration(builder.build());

            ipConfiguration.setIpAssignment(IpAssignment.STATIC);
            ipConfiguration.setStaticIpConfiguration(staticIpConfig);
        } else {
            ipConfiguration.setIpAssignment(IpAssignment.DHCP);
        }