[Wi-Fi] Remove the files which use SettingsLib Wi-Fi objects
This change removes AddDevicePreferenceController WifiDetailPreferenceController WifiMeteredPreferenceController WifiNetworkDetailsFragment WifiPrivacyPreferenceController Bug: 152571756 Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.wifi Change-Id: Id4901d632f7f4634461ebbbc096e36d348a33365
This commit is contained in:
@@ -1,135 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2016 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
|
||||||
settings:initialExpandedChildrenCount="5">
|
|
||||||
|
|
||||||
<com.android.settingslib.widget.LayoutPreference
|
|
||||||
android:key="connection_header"
|
|
||||||
android:layout="@layout/settings_entity_header"
|
|
||||||
android:selectable="false"
|
|
||||||
android:order="-10000"
|
|
||||||
settings:allowDividerBelow="true"/>
|
|
||||||
|
|
||||||
<com.android.settings.datausage.DataUsageSummaryPreference
|
|
||||||
android:key="status_header"
|
|
||||||
android:selectable="false"
|
|
||||||
settings:isPreferenceVisible="false"/>
|
|
||||||
|
|
||||||
<!-- Buttons -->
|
|
||||||
<com.android.settingslib.widget.ActionButtonsPreference
|
|
||||||
android:key="buttons"
|
|
||||||
android:selectable="false" />
|
|
||||||
|
|
||||||
<!-- General Details Preferences -->
|
|
||||||
<Preference
|
|
||||||
android:key="signal_strength"
|
|
||||||
android:title="@string/wifi_signal"
|
|
||||||
android:selectable="false"
|
|
||||||
settings:allowDividerAbove="true"/>
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="frequency"
|
|
||||||
android:icon="@drawable/ic_frequency_antenna"
|
|
||||||
android:title="@string/wifi_frequency"
|
|
||||||
android:selectable="false"/>
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="security"
|
|
||||||
android:icon="@drawable/ic_security_lock_24dp"
|
|
||||||
android:title="@string/wifi_security"
|
|
||||||
android:selectable="false"/>
|
|
||||||
|
|
||||||
<DropDownPreference
|
|
||||||
android:key="metered"
|
|
||||||
android:icon="@drawable/ic_attach_money_black_24dp"
|
|
||||||
android:title="@string/wifi_metered_title"
|
|
||||||
android:entries="@array/wifi_metered_entries"
|
|
||||||
android:entryValues="@array/wifi_metered_values"/>
|
|
||||||
|
|
||||||
<DropDownPreference
|
|
||||||
android:key="privacy"
|
|
||||||
android:icon="@drawable/ic_wifi_privacy_24dp"
|
|
||||||
android:title="@string/wifi_privacy_settings"
|
|
||||||
android:entries="@array/wifi_privacy_entries"
|
|
||||||
android:entryValues="@array/wifi_privacy_values"/>
|
|
||||||
|
|
||||||
<!-- Add device Preference -->
|
|
||||||
<Preference
|
|
||||||
android:key="add_device_to_network"
|
|
||||||
android:title="@string/wifi_dpp_add_device"
|
|
||||||
android:summary="@string/wifi_dpp_connect_network_using_qr_code"
|
|
||||||
settings:allowDividerAbove="true"/>
|
|
||||||
|
|
||||||
<!-- Network Details -->
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="ip_details_category"
|
|
||||||
android:title="@string/wifi_setup_detail">
|
|
||||||
<Preference
|
|
||||||
android:key="ssid"
|
|
||||||
android:title="@string/wifi_advanced_ssid_title"
|
|
||||||
android:selectable="false"
|
|
||||||
settings:enableCopying="true"/>
|
|
||||||
<Preference
|
|
||||||
android:key="mac_address"
|
|
||||||
android:title="@string/wifi_advanced_randomized_mac_address_title"
|
|
||||||
android:selectable="false"
|
|
||||||
settings:enableCopying="true"/>
|
|
||||||
<Preference
|
|
||||||
android:key="ip_address"
|
|
||||||
android:title="@string/wifi_ip_address"
|
|
||||||
android:selectable="false"
|
|
||||||
settings:enableCopying="true"/>
|
|
||||||
<Preference
|
|
||||||
android:key="gateway"
|
|
||||||
android:title="@string/wifi_gateway"
|
|
||||||
android:selectable="false"
|
|
||||||
settings:enableCopying="true"/>
|
|
||||||
<Preference
|
|
||||||
android:key="subnet_mask"
|
|
||||||
android:title="@string/wifi_details_subnet_mask"
|
|
||||||
android:selectable="false"
|
|
||||||
settings:enableCopying="true"/>
|
|
||||||
<Preference
|
|
||||||
android:key="dns"
|
|
||||||
android:title="@string/wifi_details_dns"
|
|
||||||
android:selectable="false"
|
|
||||||
settings:enableCopying="true"/>
|
|
||||||
<Preference
|
|
||||||
android:key="tx_link_speed"
|
|
||||||
android:title="@string/tx_wifi_speed"
|
|
||||||
android:selectable="false"
|
|
||||||
settings:enableCopying="true"/>
|
|
||||||
<Preference
|
|
||||||
android:key="rx_link_speed"
|
|
||||||
android:title="@string/rx_wifi_speed"
|
|
||||||
android:selectable="false"
|
|
||||||
settings:enableCopying="true"/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<!-- IPv6 Details -->
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="ipv6_category"
|
|
||||||
android:title="@string/wifi_details_ipv6_address_header"
|
|
||||||
android:selectable="false">
|
|
||||||
<Preference
|
|
||||||
android:key="ipv6_addresses"
|
|
||||||
android:selectable="false"
|
|
||||||
settings:enableCopying="true"/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
</PreferenceScreen>
|
|
@@ -124,7 +124,7 @@ public class AddNetworkFragment extends InstrumentedFragment implements WifiConf
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMode() {
|
public int getMode() {
|
||||||
return WifiConfigUiBase.MODE_CONNECT;
|
return WifiConfigUiBase2.MODE_CONNECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -40,7 +40,6 @@ import android.text.InputType;
|
|||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -67,7 +66,6 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
|
|
||||||
import com.android.settings.ProxySelector;
|
import com.android.settings.ProxySelector;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.wifi.details.WifiPrivacyPreferenceController;
|
|
||||||
import com.android.settings.wifi.details2.WifiPrivacyPreferenceController2;
|
import com.android.settings.wifi.details2.WifiPrivacyPreferenceController2;
|
||||||
import com.android.settings.wifi.dpp.WifiDppUtils;
|
import com.android.settings.wifi.dpp.WifiDppUtils;
|
||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
@@ -294,14 +292,8 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
? HIDDEN_NETWORK
|
? HIDDEN_NETWORK
|
||||||
: NOT_HIDDEN_NETWORK);
|
: NOT_HIDDEN_NETWORK);
|
||||||
|
|
||||||
int prefMacValue;
|
final int prefMacValue = WifiPrivacyPreferenceController2
|
||||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_WIFITRACKER2)) {
|
.translateMacRandomizedValueToPrefValue(config.macRandomizationSetting);
|
||||||
prefMacValue = WifiPrivacyPreferenceController2
|
|
||||||
.translateMacRandomizedValueToPrefValue(config.macRandomizationSetting);
|
|
||||||
} else {
|
|
||||||
prefMacValue = WifiPrivacyPreferenceController
|
|
||||||
.translateMacRandomizedValueToPrefValue(config.macRandomizationSetting);
|
|
||||||
}
|
|
||||||
mPrivacySettingsSpinner.setSelection(prefMacValue);
|
mPrivacySettingsSpinner.setSelection(prefMacValue);
|
||||||
|
|
||||||
if (config.getIpConfiguration().getIpAssignment() == IpAssignment.STATIC) {
|
if (config.getIpConfiguration().getIpAssignment() == IpAssignment.STATIC) {
|
||||||
@@ -814,15 +806,9 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mPrivacySettingsSpinner != null) {
|
if (mPrivacySettingsSpinner != null) {
|
||||||
int macValue;
|
config.macRandomizationSetting = WifiPrivacyPreferenceController2
|
||||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_WIFITRACKER2)) {
|
.translatePrefValueToMacRandomizedValue(mPrivacySettingsSpinner
|
||||||
macValue = WifiPrivacyPreferenceController2.translatePrefValueToMacRandomizedValue(
|
.getSelectedItemPosition());
|
||||||
mPrivacySettingsSpinner.getSelectedItemPosition());
|
|
||||||
} else {
|
|
||||||
macValue = WifiPrivacyPreferenceController.translatePrefValueToMacRandomizedValue(
|
|
||||||
mPrivacySettingsSpinner.getSelectedItemPosition());
|
|
||||||
}
|
|
||||||
config.macRandomizationSetting = macValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
|
@@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.details;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
import com.android.settings.wifi.dpp.WifiDppUtils;
|
|
||||||
import com.android.settingslib.wifi.AccessPoint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link BasePreferenceController} that launches Wi-Fi Easy Connect configurator flow.
|
|
||||||
*
|
|
||||||
* Migrating from Wi-Fi SettingsLib to to WifiTrackerLib, this object will be removed in the near
|
|
||||||
* future, please develop in
|
|
||||||
* {@link com.android.settings.wifi.details2.AddDevicePreferenceController2}.
|
|
||||||
*/
|
|
||||||
public class AddDevicePreferenceController extends BasePreferenceController {
|
|
||||||
|
|
||||||
private static final String TAG = "AddDevicePreferenceController";
|
|
||||||
|
|
||||||
private static final String KEY_ADD_DEVICE = "add_device_to_network";
|
|
||||||
|
|
||||||
private AccessPoint mAccessPoint;
|
|
||||||
private WifiManager mWifiManager;
|
|
||||||
|
|
||||||
public AddDevicePreferenceController(Context context) {
|
|
||||||
super(context, KEY_ADD_DEVICE);
|
|
||||||
|
|
||||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AddDevicePreferenceController init(AccessPoint accessPoint) {
|
|
||||||
mAccessPoint = accessPoint;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
if (WifiDppUtils.isSupportConfiguratorQrCodeScanner(mContext, mAccessPoint)) {
|
|
||||||
return AVAILABLE;
|
|
||||||
} else {
|
|
||||||
return CONDITIONALLY_UNAVAILABLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
|
||||||
if (KEY_ADD_DEVICE.equals(preference.getKey())) {
|
|
||||||
WifiDppUtils.showLockScreen(mContext, () -> launchWifiDppConfiguratorQrCodeScanner());
|
|
||||||
return true; /* click is handled */
|
|
||||||
}
|
|
||||||
|
|
||||||
return false; /* click is not handled */
|
|
||||||
}
|
|
||||||
|
|
||||||
private void launchWifiDppConfiguratorQrCodeScanner() {
|
|
||||||
final Intent intent = WifiDppUtils.getConfiguratorQrCodeScannerIntentOrNull(mContext,
|
|
||||||
mWifiManager, mAccessPoint);
|
|
||||||
|
|
||||||
if (intent == null) {
|
|
||||||
Log.e(TAG, "Launch Wi-Fi QR code scanner with a wrong Wi-Fi network!");
|
|
||||||
} else {
|
|
||||||
mContext.startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,112 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2018 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.details;
|
|
||||||
|
|
||||||
import android.app.backup.BackupManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.wifi.WifiConfiguration;
|
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
import androidx.preference.DropDownPreference;
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
import com.android.settings.wifi.WifiDialog;
|
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link AbstractPreferenceController} that controls whether the wifi network is metered or not.
|
|
||||||
*
|
|
||||||
* Migrating from Wi-Fi SettingsLib to to WifiTrackerLib, this object will be removed in the near
|
|
||||||
* future, please develop in
|
|
||||||
* {@link com.android.settings.wifi.details2.WifiMeteredPreferenceControlle2}.
|
|
||||||
*/
|
|
||||||
public class WifiMeteredPreferenceController extends BasePreferenceController implements
|
|
||||||
Preference.OnPreferenceChangeListener, WifiDialog.WifiDialogListener {
|
|
||||||
|
|
||||||
private static final String KEY_WIFI_METERED = "metered";
|
|
||||||
private WifiConfiguration mWifiConfiguration;
|
|
||||||
private WifiManager mWifiManager;
|
|
||||||
private Preference mPreference;
|
|
||||||
|
|
||||||
public WifiMeteredPreferenceController(Context context, WifiConfiguration wifiConfiguration) {
|
|
||||||
super(context, KEY_WIFI_METERED);
|
|
||||||
mWifiConfiguration = wifiConfiguration;
|
|
||||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateState(Preference preference) {
|
|
||||||
final DropDownPreference dropDownPreference = (DropDownPreference) preference;
|
|
||||||
final int meteredOverride = getMeteredOverride();
|
|
||||||
dropDownPreference.setValue(Integer.toString(meteredOverride));
|
|
||||||
updateSummary(dropDownPreference, meteredOverride);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
return AVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
||||||
if (mWifiConfiguration != null) {
|
|
||||||
mWifiConfiguration.meteredOverride = Integer.parseInt((String) newValue);
|
|
||||||
}
|
|
||||||
mWifiManager.updateNetwork(mWifiConfiguration);
|
|
||||||
// Stage the backup of the SettingsProvider package which backs this up
|
|
||||||
BackupManager.dataChanged("com.android.providers.settings");
|
|
||||||
updateSummary((DropDownPreference) preference, getMeteredOverride());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
int getMeteredOverride() {
|
|
||||||
if (mWifiConfiguration != null) {
|
|
||||||
// Wrap the meteredOverride since robolectric cannot recognize it
|
|
||||||
return mWifiConfiguration.meteredOverride;
|
|
||||||
}
|
|
||||||
return WifiConfiguration.METERED_OVERRIDE_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateSummary(DropDownPreference preference, int meteredOverride) {
|
|
||||||
preference.setSummary(preference.getEntries()[meteredOverride]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
|
||||||
super.displayPreference(screen);
|
|
||||||
mPreference = screen.findPreference(getPreferenceKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSubmit(WifiDialog dialog) {
|
|
||||||
if (dialog.getController() != null) {
|
|
||||||
final WifiConfiguration newConfig = dialog.getController().getConfig();
|
|
||||||
if (newConfig == null || mWifiConfiguration == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newConfig.meteredOverride != mWifiConfiguration.meteredOverride) {
|
|
||||||
mWifiConfiguration = newConfig;
|
|
||||||
onPreferenceChange(mPreference, String.valueOf(newConfig.meteredOverride));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,171 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 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.details;
|
|
||||||
|
|
||||||
import static com.android.settings.wifi.WifiSettings.WIFI_DIALOG_ID;
|
|
||||||
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.app.settings.SettingsEnums;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.ConnectivityManager;
|
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
|
||||||
import com.android.settings.wifi.WifiConfigUiBase;
|
|
||||||
import com.android.settings.wifi.WifiDialog;
|
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
|
||||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
|
||||||
import com.android.settingslib.wifi.AccessPoint;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Detail page for the currently connected wifi network.
|
|
||||||
*
|
|
||||||
* <p>The AccessPoint should be saved to the intent Extras when launching this class via
|
|
||||||
* {@link AccessPoint#saveWifiState(Bundle)} in order to properly render this page.
|
|
||||||
*
|
|
||||||
* Migrating from Wi-Fi SettingsLib to to WifiTrackerLib, this object will be removed in the near
|
|
||||||
* future, please develop in
|
|
||||||
* {@link com.android.settings.wifi.details2.WifiNetworkDetailsFragment2}.
|
|
||||||
*/
|
|
||||||
public class WifiNetworkDetailsFragment extends DashboardFragment implements
|
|
||||||
WifiDialog.WifiDialogListener {
|
|
||||||
|
|
||||||
private static final String TAG = "WifiNetworkDetailsFrg";
|
|
||||||
|
|
||||||
private AccessPoint mAccessPoint;
|
|
||||||
private WifiDetailPreferenceController mWifiDetailPreferenceController;
|
|
||||||
private List<WifiDialog.WifiDialogListener> mWifiDialogListeners = new ArrayList<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Context context) {
|
|
||||||
mAccessPoint = new AccessPoint(context, getArguments());
|
|
||||||
super.onAttach(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetricsCategory() {
|
|
||||||
return SettingsEnums.WIFI_NETWORK_DETAILS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getLogTag() {
|
|
||||||
return TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getPreferenceScreenResId() {
|
|
||||||
return R.xml.wifi_network_details_fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDialogMetricsCategory(int dialogId) {
|
|
||||||
if (dialogId == WIFI_DIALOG_ID) {
|
|
||||||
return SettingsEnums.DIALOG_WIFI_AP_EDIT;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(int dialogId) {
|
|
||||||
if (getActivity() == null || mWifiDetailPreferenceController == null
|
|
||||||
|| mAccessPoint == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return WifiDialog.createModal(getActivity(), this, mAccessPoint,
|
|
||||||
WifiConfigUiBase.MODE_MODIFY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
MenuItem item = menu.add(0, Menu.FIRST, 0, R.string.wifi_modify);
|
|
||||||
item.setIcon(com.android.internal.R.drawable.ic_mode_edit);
|
|
||||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
|
||||||
switch (menuItem.getItemId()) {
|
|
||||||
case Menu.FIRST:
|
|
||||||
if (!mWifiDetailPreferenceController.canModifyNetwork()) {
|
|
||||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(),
|
|
||||||
RestrictedLockUtilsInternal.getDeviceOwner(getContext()));
|
|
||||||
} else {
|
|
||||||
showDialog(WIFI_DIALOG_ID);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(menuItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
|
||||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
|
||||||
final ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
|
|
||||||
|
|
||||||
mWifiDetailPreferenceController = WifiDetailPreferenceController.newInstance(
|
|
||||||
mAccessPoint,
|
|
||||||
cm,
|
|
||||||
context,
|
|
||||||
this,
|
|
||||||
new Handler(Looper.getMainLooper()), // UI thread.
|
|
||||||
getSettingsLifecycle(),
|
|
||||||
context.getSystemService(WifiManager.class),
|
|
||||||
mMetricsFeatureProvider);
|
|
||||||
|
|
||||||
controllers.add(mWifiDetailPreferenceController);
|
|
||||||
controllers.add(new AddDevicePreferenceController(context).init(mAccessPoint));
|
|
||||||
|
|
||||||
final WifiMeteredPreferenceController meteredPreferenceController =
|
|
||||||
new WifiMeteredPreferenceController(context, mAccessPoint.getConfig());
|
|
||||||
controllers.add(meteredPreferenceController);
|
|
||||||
|
|
||||||
final WifiPrivacyPreferenceController privacyController =
|
|
||||||
new WifiPrivacyPreferenceController(context);
|
|
||||||
privacyController.setWifiConfiguration(mAccessPoint.getConfig());
|
|
||||||
privacyController.setIsEphemeral(mAccessPoint.isEphemeral());
|
|
||||||
privacyController.setIsPasspoint(
|
|
||||||
mAccessPoint.isPasspoint() || mAccessPoint.isPasspointConfig());
|
|
||||||
controllers.add(privacyController);
|
|
||||||
|
|
||||||
// Sets callback listener for wifi dialog.
|
|
||||||
mWifiDialogListeners.add(mWifiDetailPreferenceController);
|
|
||||||
mWifiDialogListeners.add(privacyController);
|
|
||||||
mWifiDialogListeners.add(meteredPreferenceController);
|
|
||||||
|
|
||||||
return controllers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSubmit(WifiDialog dialog) {
|
|
||||||
for (WifiDialog.WifiDialogListener listener : mWifiDialogListeners) {
|
|
||||||
listener.onSubmit(dialog);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -11,5 +11,4 @@ com.android.settings.fuelgauge.RestrictAppPreferenceController
|
|||||||
com.android.settings.fuelgauge.batterysaver.BatterySaverButtonPreferenceController
|
com.android.settings.fuelgauge.batterysaver.BatterySaverButtonPreferenceController
|
||||||
com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController
|
com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController
|
||||||
com.android.settings.security.VisiblePatternProfilePreferenceController
|
com.android.settings.security.VisiblePatternProfilePreferenceController
|
||||||
com.android.settings.wifi.details.WifiMeteredPreferenceController
|
|
||||||
com.android.settings.wifi.details2.WifiMeteredPreferenceController2
|
com.android.settings.wifi.details2.WifiMeteredPreferenceController2
|
||||||
|
@@ -55,7 +55,7 @@ public class AddNetworkFragmentTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMode_shouldBeModeConnected() {
|
public void getMode_shouldBeModeConnected() {
|
||||||
assertThat(mAddNetworkFragment.getMode()).isEqualTo(WifiConfigUiBase.MODE_CONNECT);
|
assertThat(mAddNetworkFragment.getMode()).isEqualTo(WifiConfigUiBase2.MODE_CONNECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -68,7 +68,7 @@ public class ConfigureWifiEntryFragmentTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getMode_shouldBeModeConnected() {
|
public void getMode_shouldBeModeConnected() {
|
||||||
assertThat(mConfigureWifiEntryFragment.getMode()).isEqualTo(
|
assertThat(mConfigureWifiEntryFragment.getMode()).isEqualTo(
|
||||||
WifiConfigUiBase.MODE_CONNECT);
|
WifiConfigUiBase2.MODE_CONNECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -43,7 +43,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
|
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
|
||||||
import com.android.settings.wifi.details.WifiPrivacyPreferenceController;
|
import com.android.settings.wifi.details2.WifiPrivacyPreferenceController2;
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -249,7 +249,7 @@ public class WifiConfigController2Test {
|
|||||||
@Test
|
@Test
|
||||||
public void loadCertificates_undesiredCertificates_shouldNotLoadUndesiredCertificates() {
|
public void loadCertificates_undesiredCertificates_shouldNotLoadUndesiredCertificates() {
|
||||||
final Spinner spinner = new Spinner(mContext);
|
final Spinner spinner = new Spinner(mContext);
|
||||||
when(mKeyStore.list(anyString())).thenReturn(WifiConfigController.UNDESIRED_CERTIFICATES);
|
when(mKeyStore.list(anyString())).thenReturn(WifiConfigController2.UNDESIRED_CERTIFICATES);
|
||||||
|
|
||||||
mController.loadCertificates(spinner,
|
mController.loadCertificates(spinner,
|
||||||
"prefix",
|
"prefix",
|
||||||
@@ -392,7 +392,7 @@ public class WifiConfigController2Test {
|
|||||||
public void loadMacRandomizedValue_shouldPersistentAsDefault() {
|
public void loadMacRandomizedValue_shouldPersistentAsDefault() {
|
||||||
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
||||||
final int prefPersist =
|
final int prefPersist =
|
||||||
WifiPrivacyPreferenceController.translateMacRandomizedValueToPrefValue(
|
WifiPrivacyPreferenceController2.translateMacRandomizedValueToPrefValue(
|
||||||
WifiConfiguration.RANDOMIZATION_PERSISTENT);
|
WifiConfiguration.RANDOMIZATION_PERSISTENT);
|
||||||
|
|
||||||
assertThat(privacySetting.getVisibility()).isEqualTo(View.VISIBLE);
|
assertThat(privacySetting.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
@@ -420,7 +420,7 @@ public class WifiConfigController2Test {
|
|||||||
|
|
||||||
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
||||||
final int expectedPrefValue =
|
final int expectedPrefValue =
|
||||||
WifiPrivacyPreferenceController.translateMacRandomizedValueToPrefValue(
|
WifiPrivacyPreferenceController2.translateMacRandomizedValueToPrefValue(
|
||||||
macRandomizedValue);
|
macRandomizedValue);
|
||||||
|
|
||||||
assertThat(privacySetting.getVisibility()).isEqualTo(View.VISIBLE);
|
assertThat(privacySetting.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
@@ -438,7 +438,7 @@ public class WifiConfigController2Test {
|
|||||||
public void saveMacRandomizedValue_ChangedToNone_shouldGetNone() {
|
public void saveMacRandomizedValue_ChangedToNone_shouldGetNone() {
|
||||||
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
|
||||||
final int prefMacNone =
|
final int prefMacNone =
|
||||||
WifiPrivacyPreferenceController.translateMacRandomizedValueToPrefValue(
|
WifiPrivacyPreferenceController2.translateMacRandomizedValueToPrefValue(
|
||||||
WifiConfiguration.RANDOMIZATION_NONE);
|
WifiConfiguration.RANDOMIZATION_NONE);
|
||||||
privacySetting.setSelection(prefMacNone);
|
privacySetting.setSelection(prefMacNone);
|
||||||
|
|
||||||
|
@@ -1,57 +0,0 @@
|
|||||||
package com.android.settings.wifi;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
|
|
||||||
import com.android.settings.wifi.WifiDialog.WifiDialogListener;
|
|
||||||
import com.android.settingslib.wifi.AccessPoint;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
import org.robolectric.annotation.Config;
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
@Config(shadows = ShadowEntityHeaderController.class)
|
|
||||||
public class WifiDialogTest {
|
|
||||||
@Mock private AccessPoint mockAccessPoint;
|
|
||||||
|
|
||||||
private Context mContext = RuntimeEnvironment.application;
|
|
||||||
|
|
||||||
private WifiDialogListener mListener = new WifiDialogListener() {};
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void createModal_usesDefaultTheme() {
|
|
||||||
WifiDialog modal = WifiDialog
|
|
||||||
.createModal(mContext, mListener, mockAccessPoint, WifiConfigUiBase.MODE_CONNECT);
|
|
||||||
|
|
||||||
WifiDialog wifiDialog = new WifiDialog(mContext, mListener, mockAccessPoint,
|
|
||||||
WifiConfigUiBase.MODE_CONNECT, 0 /* style */, false /* hideSubmitButton */);
|
|
||||||
assertThat(modal.getContext().getThemeResId())
|
|
||||||
.isEqualTo(wifiDialog.getContext().getThemeResId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void createModal_whenSetTheme_shouldBeCustomizedTheme() {
|
|
||||||
WifiDialog modal = WifiDialog.createModal(mContext, mListener, mockAccessPoint,
|
|
||||||
WifiConfigUiBase.MODE_CONNECT, R.style.SuwAlertDialogThemeCompat_Light);
|
|
||||||
|
|
||||||
WifiDialog wifiDialog = new WifiDialog(mContext, mListener, mockAccessPoint,
|
|
||||||
WifiConfigUiBase.MODE_CONNECT, R.style.SuwAlertDialogThemeCompat_Light,
|
|
||||||
false /* hideSubmitButton */);
|
|
||||||
assertThat(modal.getContext().getThemeResId())
|
|
||||||
.isEqualTo(wifiDialog.getContext().getThemeResId());
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,96 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2018 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.details;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.doReturn;
|
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.wifi.WifiConfiguration;
|
|
||||||
|
|
||||||
import androidx.preference.DropDownPreference;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class WifiMeteredPreferenceControllerTest {
|
|
||||||
|
|
||||||
private static final int METERED_OVERRIDE_NONE = 0;
|
|
||||||
private static final int METERED_OVERRIDE_METERED = 1;
|
|
||||||
private static final int METERED_OVERRIDE_NOT_METERED = 2;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private WifiConfiguration mWifiConfiguration;
|
|
||||||
|
|
||||||
private WifiMeteredPreferenceController mPreferenceController;
|
|
||||||
private Context mContext;
|
|
||||||
private DropDownPreference mDropDownPreference;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
mContext = RuntimeEnvironment.application;
|
|
||||||
|
|
||||||
mPreferenceController = spy(
|
|
||||||
new WifiMeteredPreferenceController(mContext, mWifiConfiguration));
|
|
||||||
mDropDownPreference = new DropDownPreference(mContext);
|
|
||||||
mDropDownPreference.setEntries(R.array.wifi_metered_entries);
|
|
||||||
mDropDownPreference.setEntryValues(R.array.wifi_metered_values);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdateState_wifiMetered_setCorrectValue() {
|
|
||||||
doReturn(METERED_OVERRIDE_METERED).when(mPreferenceController).getMeteredOverride();
|
|
||||||
|
|
||||||
mPreferenceController.updateState(mDropDownPreference);
|
|
||||||
|
|
||||||
assertThat(mDropDownPreference.getEntry()).isEqualTo("Treat as metered");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdateState_wifiNotMetered_setCorrectValue() {
|
|
||||||
doReturn(METERED_OVERRIDE_NOT_METERED).when(mPreferenceController).getMeteredOverride();
|
|
||||||
|
|
||||||
mPreferenceController.updateState(mDropDownPreference);
|
|
||||||
|
|
||||||
assertThat(mDropDownPreference.getEntry()).isEqualTo("Treat as unmetered");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdateState_wifiAuto_setCorrectValue() {
|
|
||||||
doReturn(METERED_OVERRIDE_NONE).when(mPreferenceController).getMeteredOverride();
|
|
||||||
|
|
||||||
mPreferenceController.updateState(mDropDownPreference);
|
|
||||||
|
|
||||||
assertThat(mDropDownPreference.getEntry()).isEqualTo("Detect automatically");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testController_resilientToNullConfig() {
|
|
||||||
mPreferenceController = spy(new WifiMeteredPreferenceController(mContext, null));
|
|
||||||
|
|
||||||
mPreferenceController.getMeteredOverride();
|
|
||||||
mPreferenceController.onPreferenceChange(mDropDownPreference, 1);
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user