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

Commit b60e91bf authored by Arc Wang's avatar Arc Wang
Browse files

[Wi-Fi] Replace WifiTracker with WifiTracker2 in WifiDetailPreferenceController2

There are still many methods not implemented in WifiEntry. This change has below workarounds:

1. Add WifiEntryShell to provide dummy WifiEntry methods.
2. Add @Ignore to WifiDetailPreferenceController2Test.

Must remove these workarounds after we have more constructed WifiEntry methods.

Bug: 143326832
Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.wifi.details2
      make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.wifi.savedaccesspoints2
      make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.wifi
Change-Id: Ic2edb424b9c645838558fe131991ccb9105dc64c
parent 5921312f
Loading
Loading
Loading
Loading
+131 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.wifi;

import android.net.NetworkInfo.DetailedState;

import com.android.wifitrackerlib.WifiEntry;

/**
 * {@link WifiEntry is working in progess, many methods are not available, this class is to group
 * all the unavalable {@link AccessPoint} methods & constants.
 *
 * TODO(b/143326832): Replace all methods & constants with WifiEntry version when it's available.
 * TODO(b/143326832): How about AccessPoint#getSettingsSummary(boolean convertSavedAsDisconnected)?
 */
public class WifiEntryShell {
    public WifiEntryShell(){};

    /**
     * Lower bound on the 2.4 GHz (802.11b/g/n) WLAN channels
     */
    public static final int LOWER_FREQ_24GHZ = 2400;

    /**
     * Upper bound on the 2.4 GHz (802.11b/g/n) WLAN channels
     */
    public static final int HIGHER_FREQ_24GHZ = 2500;

    /**
     * Lower bound on the 5.0 GHz (802.11a/h/j/n/ac) WLAN channels
     */
    public static final int LOWER_FREQ_5GHZ = 4900;

    /**
     * Upper bound on the 5.0 GHz (802.11a/h/j/n/ac) WLAN channels
     */
    public static final int HIGHER_FREQ_5GHZ = 5900;

    /**
     * Mapping of the corresponding {@link WifiConfiguration} field
     */
    public static int getNetworkId(WifiEntry wifiEntry) {
        return 0;
    }

    /**
     * Mapping of the corresponding {@link WifiConfiguration} field
     */
    public static boolean hiddenSSID(WifiEntry wifiEntry) {
        return false;
    }

    /**
     * Mapping of the corresponding {@link WifiDetailPreferenceController} method
     */
    public static boolean canModifyNetwork(WifiEntry wifiEntry) {
        return false;
    }

    /**
     * Mapping of the corresponding {@link AccessPoint} method
     */
    public static String getSecurityString(WifiEntry wifiEntry, boolean concise) {
        return "None";
    }

    /**
     * Mapping of the corresponding {@link AccessPoint} method
     */
    public static DetailedState getDetailedState(WifiEntry wifiEntry) {
        return null;
    }

    // Passpoint methods

    /**
     * Mapping of the corresponding {@link AccessPoint} method
     */
    public static boolean isPasspoint(WifiEntry wifiEntry) {
        return false;
    }

    /**
     * Mapping of the corresponding {@link AccessPoint} method
     */
    public static boolean isExpired(WifiEntry wifiEntry) {
        return false;
    }

    /**
     * Mapping of the corresponding {@link AccessPoint} method
     */
    public static boolean isPasspointConfigurationR1(WifiEntry wifiEntry) {
        return false;
    }

    /**
     * Mapping of the corresponding {@link AccessPoint} method
     */
    public static boolean isPasspointConfigurationOsuProvisioned(WifiEntry wifiEntry) {
        return false;
    }

    /**
     * Mapping of the corresponding {@link AccessPoint} method
     */
    public static boolean isOsuProvider(WifiEntry wifiEntry) {
        return false;
    }

    /**
     * Mapping of the corresponding {@link AccessPoint} method
     */
    public static String getPasspointFqdn(WifiEntry wifiEntry) {
        return "Fake passpoint FQDN";
    }
}
+6 −11
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ import androidx.preference.Preference;

import com.android.settings.core.BasePreferenceController;
import com.android.settings.wifi.dpp.WifiDppUtils;
import com.android.settingslib.wifi.AccessPoint;
import com.android.wifitrackerlib.WifiEntry;

/**
 * {@link BasePreferenceController} that launches Wi-Fi Easy Connect configurator flow
@@ -36,7 +36,7 @@ public class AddDevicePreferenceController2 extends BasePreferenceController {

    private static final String KEY_ADD_DEVICE = "add_device_to_network";

    private AccessPoint mAccessPoint;
    private WifiEntry mWifiEntry;
    private WifiManager mWifiManager;

    public AddDevicePreferenceController2(Context context) {
@@ -45,18 +45,13 @@ public class AddDevicePreferenceController2 extends BasePreferenceController {
        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    }

    /**
     * Initiate with an {@link AccessPoint}.
     */
    public AddDevicePreferenceController2 init(AccessPoint accessPoint) {
        mAccessPoint = accessPoint;

        return this;
    public void setWifiEntry(WifiEntry wifiEntry) {
        mWifiEntry = wifiEntry;
    }

    @Override
    public int getAvailabilityStatus() {
        if (WifiDppUtils.isSupportConfiguratorQrCodeScanner(mContext, mAccessPoint)) {
        if (WifiDppUtils.isSupportConfiguratorQrCodeScanner(mContext, mWifiEntry)) {
            return AVAILABLE;
        } else {
            return CONDITIONALLY_UNAVAILABLE;
@@ -75,7 +70,7 @@ public class AddDevicePreferenceController2 extends BasePreferenceController {

    private void launchWifiDppConfiguratorQrCodeScanner() {
        final Intent intent = WifiDppUtils.getConfiguratorQrCodeScannerIntentOrNull(mContext,
                mWifiManager, mAccessPoint);
                mWifiManager, mWifiEntry);

        if (intent == null) {
            Log.e(TAG, "Launch Wi-Fi QR code scanner with a wrong Wi-Fi network!");
Loading