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

Commit ad39d9b1 authored by Chiachang Wang's avatar Chiachang Wang
Browse files

Remove hidden connectivity method usage

Becuase of modulization work for connectivity module, the
connectivity hidden methods are not accessible outside the
module. This commit replace the hidden methods usage under
ConnectivityManagerTest.

Bug: 182859030
Test: Remove framework-connectivity from the private API ; atest
Change-Id: I5e23bd0ab2e82fc3583c56162d5ac3fec6cfc359
Merged-In: I5e23bd0ab2e82fc3583c56162d5ac3fec6cfc359
parent 23bbd41f
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);
        }