Merge "Fix incorrect UI issue of "previously connected devices""
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c73ee8d..d2bdc9f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -493,6 +493,7 @@
android:icon="@drawable/ic_settings_wireless">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
+ <action android:name="android.settings.TETHER_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
</intent-filter>
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index 18ad3b5..a3ad4207 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -470,7 +470,7 @@
<EditText android:id="@+id/proxy_pac"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/wifi_item_edit_content"
+ style="@style/wifi_item_content"
android:hint="@string/proxy_url_hint"
android:inputType="textNoSuggestions"
android:singleLine="true"/>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index bfffce0..c19b948 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -276,24 +276,14 @@
<item>Require all non-trusted certificate statuses</item>
</string-array>
- <!-- Wi-Fi AP band settings. Either Auto, 2.4GHz or 5GHz. -->
+ <!-- Wi-Fi AP band settings. Either 2.4GHz or 5GHz prefer. -->
<!-- Note that adding/removing/moving the items will need wifi settings code change. -->
- <string-array translatable="false" name="wifi_ap_band_config_full">
- <item>1</item>
- <item>2</item>
- </string-array>
-
- <string-array translatable="false" name="wifi_ap_band_summary_full">
- <item>@string/wifi_ap_choose_2G</item>
- <item>@string/wifi_ap_choose_5G</item>
- </string-array>
-
- <string-array translatable="false" name="wifi_ap_band_dual_mode">
+ <string-array translatable="false" name="wifi_ap_band">
<item>1</item>
<item>3</item>
</string-array>
- <string-array translatable="false" name="wifi_ap_band_dual_mode_summary">
+ <string-array translatable="false" name="wifi_ap_band_summary">
<item>@string/wifi_ap_choose_2G</item>
<item>@string/wifi_ap_prefer_5G</item>
</string-array>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ad56f21..bf97f1d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2126,7 +2126,7 @@
<!-- Warning message displayed if user does not specify a user certification for
WPA3-Enterprise 192-bit. Only displayed if the user does not specify user certificate
for WPA3-Enterprise 192-bit [CHAR LIMIT=80]-->
- <string name="wifi_no_user_cert_warning">This option requires a user certificate.</string>
+ <string name="wifi_no_user_cert_warning">Certificate required.</string>
<!-- Substring of status line when Wi-Fi Protected Setup (WPS) is available and
string is listed first [CHAR LIMIT=20]-->
<string name="wifi_wps_available_first_item">WPS available</string>
@@ -2333,7 +2333,7 @@
<!-- Title for the toggle to turn off hotspot automatically [CHAR LIMIT=NONE]-->
<string name="wifi_hotspot_auto_off_title">Turn off hotspot automatically</string>
<!-- Summary for the toggle to turn off hotspot automatically [CHAR LIMIT=NONE]-->
- <string name="wifi_hotspot_auto_off_summary">Wi\u2011Fi hotspot will turn off if no devices are connected</string>
+ <string name="wifi_hotspot_auto_off_summary">When no devices are connected</string>
<!-- Summary text when turning hotspot on -->
<string name="wifi_tether_starting">Turning hotspot on\u2026</string>
@@ -2354,17 +2354,21 @@
<!-- Title for the panel of add Wi-Fi network from APP [CHAR LIMIT=50] -->
<string name="wifi_add_app_single_network_title">Save this network?</string>
<!-- Summary for the panel of add Wi-Fi network from APP [CHAR LIMIT=NONE] -->
- <string name="wifi_add_app_single_network_summary"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save a network to your phone</string>
+ <string name="wifi_add_app_single_network_summary" product="default"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save a network to your phone</string>
+ <!-- Summary for the panel of add Wi-Fi network from APP [CHAR LIMIT=NONE] -->
+ <string name="wifi_add_app_single_network_summary" product="tablet"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save a network to your tablet</string>
<!-- Summary for saving status when saving single network [CHAR LIMIT=30] -->
<string name="wifi_add_app_single_network_saving_summary">Saving\u2026</string>
<!-- Summary for saved status when saving single network [CHAR LIMIT=30] -->
<string name="wifi_add_app_single_network_saved_summary">Saved</string>
<!-- Summary for save failed status when saving single network [CHAR LIMIT=50] -->
- <string name="wifi_add_app_network_save_failed_summary">Couldn\u2019t save. Try again.</string>
+ <string name="wifi_add_app_network_save_failed_summary">Can\u2019t save. Try again.</string>
<!-- Title for the panel of add multiple Wi-Fi networks from APP [CHAR LIMIT=50] -->
<string name="wifi_add_app_networks_title">Save networks?</string>
<!-- Summary for the panel of add multiple Wi-Fi networks from APP [CHAR LIMIT=NONE] -->
- <string name="wifi_add_app_networks_summary"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save these networks to your phone</string>
+ <string name="wifi_add_app_networks_summary" product="default"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save these networks to your phone</string>
+ <!-- Summary for the panel of add multiple Wi-Fi networks from APP [CHAR LIMIT=NONE] -->
+ <string name="wifi_add_app_networks_summary" product="tablet"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save these networks to your tablet</string>
<!-- Summary for the panel of add Wi-Fi networks from APP [CHAR LIMIT=NONE] -->
<string name="wifi_add_app_networks_saving_summary">Saving <xliff:g id="number" example="3">%d</xliff:g> networks\u2026</string>
<!-- Summary for saved status when saving multiple networks [CHAR LIMIT=NONE] -->
@@ -2529,6 +2533,8 @@
<!-- Message to display when carrier does not support wifi calling or doesn't want the user
to modify the settings [CHAR LIMIT=NONE] -->
<string name="wifi_calling_not_supported">Wi\u2011Fi calling is not supported for %1$s</string>
+ <!-- Hint for a Wi-Fi network is disconnected successfully [CHAR LIMIT=NONE] -->
+ <string name="wifi_disconnected_from">Disconnected from <xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g></string>
<!-- Carrier string to use in other messages -->
<string name="carrier">Carrier</string>
<!-- Sound and alerts settings -->
@@ -5028,28 +5034,28 @@
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_extremely_short_delay">
- <item quantity="one">Extremely short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
- <item quantity="other">Extremely short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
+ <item quantity="one">Extremely short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
+ <item quantity="other">Extremely short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals>
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_very_short_delay">
- <item quantity="one">Very short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
- <item quantity="other">Very short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
+ <item quantity="one">Very short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
+ <item quantity="other">Very short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals>
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_short_delay">
- <item quantity="one">Short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
- <item quantity="other">Short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
+ <item quantity="one">Short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
+ <item quantity="other">Short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals>
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_long_delay">
- <item quantity="one">Long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
- <item quantity="other">Long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
+ <item quantity="one">Long delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
+ <item quantity="other">Long delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals>
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_very_long_delay">
- <item quantity="one">Very long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
- <item quantity="other">Very long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
+ <item quantity="one">Very long delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
+ <item quantity="other">Very long delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals>
<!-- Summary for autoclick seekbar settings preference when user selected custom item. [CHAR LIMIT=35] -->
@@ -9132,6 +9138,8 @@
<string name="app_permissions">Permission manager</string>
<!-- Summary of permissions currently granted to apps [CHAR LIMIT=60] -->
<string name="app_permissions_summary">Apps using <xliff:g id="apps" example="location">%1$s</xliff:g></string>
+ <!-- Summary of permissions currently granted to apps [CHAR LIMIT=60] -->
+ <string name="app_permissions_summary_more">Apps using <xliff:g id="apps" example="location">%1$s</xliff:g>, and more</string>
<!-- Label for tap to wake setting [CHAR LIMIT=30] -->
<string name="tap_to_wake">Tap to wake</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 33a2022..a4c82b2 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -141,7 +141,7 @@
<item name="android:textSize">14sp</item>
</style>
- <style name="wifi_item_edit_content" parent="@android:style/TextAppearance.Widget.EditText">
+ <style name="wifi_item_edit_content">
<item name="android:paddingStart">4dip</item>
<item name="android:layout_marginStart">4dip</item>
<item name="android:textSize">18sp</item>
diff --git a/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java b/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java
index 9079c31..301d8dc 100644
--- a/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java
+++ b/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java
@@ -19,10 +19,8 @@
import static android.content.Context.MODE_PRIVATE;
import static com.android.settings.accessibility.ToggleAutoclickPreferenceController.KEY_DELAY_MODE;
+import static com.android.settings.accessibility.ToggleAutoclickPreferenceFragment.Quantity;
-import static java.lang.annotation.RetentionPolicy.SOURCE;
-
-import android.annotation.IntDef;
import android.content.ContentResolver;
import android.content.Context;
import android.content.SharedPreferences;
@@ -42,8 +40,6 @@
import com.android.settingslib.core.lifecycle.events.OnResume;
import com.android.settingslib.widget.LayoutPreference;
-import java.lang.annotation.Retention;
-
/**
* Controller class that controls accessibility autoclick seekbar settings.
*/
@@ -51,16 +47,6 @@
implements LifecycleObserver, OnResume, OnPause,
SharedPreferences.OnSharedPreferenceChangeListener {
- @Retention(SOURCE)
- @IntDef({
- Quantity.OTHER,
- Quantity.ONE
- })
- @interface Quantity {
- int OTHER = 0;
- int ONE = 1;
- }
-
private static final String CONTROL_AUTOCLICK_DELAY_SECURE =
Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY;
private static final String KEY_CUSTOM_DELAY_VALUE = "custom_delay_value";
diff --git a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
index 4a88956..5e09b2a 100644
--- a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
@@ -19,6 +19,9 @@
import static com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController.MAX_AUTOCLICK_DELAY_MS;
import static com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController.MIN_AUTOCLICK_DELAY_MS;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+import android.annotation.IntDef;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.res.Resources;
@@ -32,6 +35,7 @@
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexable;
+import java.lang.annotation.Retention;
import java.util.ArrayList;
import java.util.List;
@@ -46,6 +50,16 @@
private static final String TAG = "AutoclickPrefFragment";
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
+ @Retention(SOURCE)
+ @IntDef({
+ Quantity.OTHER,
+ Quantity.ONE
+ })
+ @interface Quantity {
+ int OTHER = 0;
+ int ONE = 1;
+ }
+
/**
* Resource ids from which autoclick preference summaries should be derived. The strings have
* placeholder for integer delay value.
@@ -63,12 +77,17 @@
* delay.
*
* @param resources Resources from which string should be retrieved.
- * @param delay Delay for whose value summary should be retrieved.
+ * @param delayMillis Delay for whose value summary should be retrieved.
*/
- static CharSequence getAutoclickPreferenceSummary(Resources resources, int delay) {
- int summaryIndex = getAutoclickPreferenceSummaryIndex(delay);
- return resources.getQuantityString(
- mAutoclickPreferenceSummaries[summaryIndex], delay, delay);
+ static CharSequence getAutoclickPreferenceSummary(Resources resources, int delayMillis) {
+ final int summaryIndex = getAutoclickPreferenceSummaryIndex(delayMillis);
+ final int quantity = (delayMillis == 1000) ? Quantity.ONE : Quantity.OTHER;
+ final float delaySecond = (float) delayMillis / 1000;
+ // Only show integer when delay time is 1.
+ final String decimalFormat = (delaySecond == 1) ? "%.0f" : "%.1f";
+
+ return resources.getQuantityString(mAutoclickPreferenceSummaries[summaryIndex],
+ quantity, String.format(decimalFormat, delaySecond));
}
/**
diff --git a/src/com/android/settings/applications/AppHeaderPreferenceController.java b/src/com/android/settings/applications/AppHeaderPreferenceController.java
index 8a77d6f..0f473e7 100644
--- a/src/com/android/settings/applications/AppHeaderPreferenceController.java
+++ b/src/com/android/settings/applications/AppHeaderPreferenceController.java
@@ -21,11 +21,11 @@
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
-import android.util.IconDrawableFactory;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.widget.EntityHeaderController;
@@ -94,8 +94,7 @@
EntityHeaderController
.newInstance(activity, mParent, mHeaderPreference.findViewById(R.id.entity_header))
.setRecyclerView(mParent.getListView(), mLifecycle)
- .setIcon(IconDrawableFactory.newInstance(activity).getBadgedIcon(
- mPackageInfo.applicationInfo))
+ .setIcon(Utils.getBadgedIcon(mParent.getContext(), mPackageInfo.applicationInfo))
.setLabel(mPackageInfo.applicationInfo.loadLabel(packageManager))
.setSummary(mPackageInfo)
.setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
diff --git a/src/com/android/settings/applications/AppInfoWithHeader.java b/src/com/android/settings/applications/AppInfoWithHeader.java
index 9e3842e..7bf9f64 100644
--- a/src/com/android/settings/applications/AppInfoWithHeader.java
+++ b/src/com/android/settings/applications/AppInfoWithHeader.java
@@ -20,11 +20,11 @@
import android.app.Activity;
import android.os.Bundle;
-import android.util.IconDrawableFactory;
import android.util.Log;
import androidx.preference.Preference;
+import com.android.settings.Utils;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.applications.AppUtils;
@@ -47,8 +47,7 @@
final Preference pref = EntityHeaderController
.newInstance(activity, this, null /* header */)
.setRecyclerView(getListView(), getSettingsLifecycle())
- .setIcon(IconDrawableFactory.newInstance(getContext())
- .getBadgedIcon(mPackageInfo.applicationInfo))
+ .setIcon(Utils.getBadgedIcon(getContext(), mPackageInfo.applicationInfo))
.setLabel(mPackageInfo.applicationInfo.loadLabel(mPm))
.setSummary(mPackageInfo)
.setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
diff --git a/src/com/android/settings/applications/AppPermissionsPreferenceController.java b/src/com/android/settings/applications/AppPermissionsPreferenceController.java
index 0a3bba7..4458ea4 100644
--- a/src/com/android/settings/applications/AppPermissionsPreferenceController.java
+++ b/src/com/android/settings/applications/AppPermissionsPreferenceController.java
@@ -33,7 +33,7 @@
public class AppPermissionsPreferenceController extends BasePreferenceController {
private static final String TAG = "AppPermissionPrefCtrl";
- private static int NUM_PACKAGE_TO_CHECK = 3;
+ private static final int NUM_PACKAGE_TO_CHECK = 4;
@VisibleForTesting
static int NUM_PERMISSIONS_TO_SHOW = 3;
@@ -78,7 +78,7 @@
void queryPermissionSummary() {
final List<PackageInfo> installedPackages =
mPackageManager.getInstalledPackages(PackageManager.GET_PERMISSIONS);
- // Here we only get the first three apps and check their permissions.
+ // Here we only get the first four apps and check their permissions.
final List<PackageInfo> packagesWithPermission = installedPackages.stream()
.filter(pInfo -> pInfo.permissions != null)
.limit(NUM_PACKAGE_TO_CHECK)
@@ -102,10 +102,21 @@
final List<CharSequence> permissionsToShow = mPermissionGroups.stream()
.limit(NUM_PERMISSIONS_TO_SHOW)
.collect(Collectors.toList());
- final CharSequence summary = !permissionsToShow.isEmpty()
- ? mContext.getString(R.string.app_permissions_summary,
- ListFormatter.getInstance().format(permissionsToShow).toLowerCase())
- : mContext.getString(R.string.runtime_permissions_summary_no_permissions_granted);
+ final boolean isMoreShowed = mPermissionGroups.size() > NUM_PERMISSIONS_TO_SHOW;
+ CharSequence summary;
+
+ if (!permissionsToShow.isEmpty()) {
+ if (isMoreShowed) {
+ summary = mContext.getString(R.string.app_permissions_summary_more,
+ ListFormatter.getInstance().format(permissionsToShow).toLowerCase());
+ } else {
+ summary = mContext.getString(R.string.app_permissions_summary,
+ ListFormatter.getInstance().format(permissionsToShow).toLowerCase());
+ }
+ } else {
+ summary = mContext.getString(
+ R.string.runtime_permissions_summary_no_permissions_granted);
+ }
mPreference.setSummary(summary);
}
}
\ No newline at end of file
diff --git a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
index 0f429c7..128f4da 100644
--- a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
+++ b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
@@ -83,7 +83,7 @@
final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig();
synchronized (mBluetoothA2dpConfigStore) {
if (mBluetoothA2dp != null) {
- setCodecConfigPreference(null, codecConfig); // Use current active device
+ setCodecConfigPreference(mBluetoothA2dp.getActiveDevice(), codecConfig);
}
}
// Because the setting is not persisted into permanent storage, we cannot call update state
@@ -102,13 +102,14 @@
@Override
public void updateState(Preference preference) {
- if (getCodecConfig(null) == null || mPreference == null) { // Use current active device
+ BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
+ if (getCodecConfig(activeDevice) == null || mPreference == null) {
return;
}
BluetoothCodecConfig codecConfig;
synchronized (mBluetoothA2dpConfigStore) {
- codecConfig = getCodecConfig(null); // Use current active device
+ codecConfig = getCodecConfig(activeDevice);
}
final int index = getCurrentA2dpSettingIndex(codecConfig);
diff --git a/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java b/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java
index 71907b6..6f1eab0 100644
--- a/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java
+++ b/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java
@@ -80,7 +80,7 @@
}
writeConfigurationValues(index);
final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig();
- bluetoothA2dp.setCodecConfigPreference(null, codecConfig);
+ bluetoothA2dp.setCodecConfigPreference(bluetoothA2dp.getActiveDevice(), codecConfig);
mPreference.setSummary(((BaseBluetoothDialogPreference) mPreference).generateSummary(
index));
}
@@ -146,7 +146,8 @@
if (bluetoothA2dp == null) {
return null;
}
- final BluetoothCodecStatus codecStatus = bluetoothA2dp.getCodecStatus(null);
+ final BluetoothCodecStatus codecStatus =
+ bluetoothA2dp.getCodecStatus(bluetoothA2dp.getActiveDevice());
if (codecStatus == null) {
Log.d(TAG, "Unable to get current codec config. Codec status is null");
return null;
@@ -177,7 +178,8 @@
* @return {@link BluetoothCodecConfig}.
*/
protected BluetoothCodecConfig getSelectableByCodecType(int codecTypeValue) {
- final BluetoothCodecConfig[] configs = getSelectableConfigs(null);
+ final BluetoothCodecConfig[] configs = getSelectableConfigs(
+ mBluetoothA2dp.getActiveDevice());
if (configs == null) {
Log.d(TAG, "Unable to get selectable config. Selectable configs is empty.");
return null;
diff --git a/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java b/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java
index c2977a8..8eecec9 100644
--- a/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java
+++ b/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java
@@ -83,9 +83,9 @@
return index;
}
// Check HD audio is enabled, display the available list.
- if (bluetoothA2dp.getOptionalCodecsEnabled(activeDevice)
+ if (bluetoothA2dp.isOptionalCodecsEnabled(activeDevice)
== BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) {
- BluetoothCodecConfig[] configs = getSelectableConfigs(null);
+ BluetoothCodecConfig[] configs = getSelectableConfigs(bluetoothA2dp.getActiveDevice());
if (configs != null) {
return getIndexFromConfig(configs);
}
@@ -101,7 +101,8 @@
int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
switch (index) {
case 0:
- codecTypeValue = getHighestCodec(getSelectableConfigs(null));
+ codecTypeValue = getHighestCodec(getSelectableConfigs(
+ mBluetoothA2dp.getActiveDevice()));
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
break;
case 1:
diff --git a/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java b/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java
index 8008188..714b9ab 100644
--- a/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java
+++ b/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java
@@ -58,11 +58,11 @@
mPreference.setEnabled(false);
return;
}
- final boolean supported = (bluetoothA2dp.supportsOptionalCodecs(activeDevice)
+ final boolean supported = (bluetoothA2dp.isOptionalCodecsSupported(activeDevice)
== BluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
mPreference.setEnabled(supported);
if (supported) {
- final boolean isEnabled = bluetoothA2dp.getOptionalCodecsEnabled(activeDevice)
+ final boolean isEnabled = bluetoothA2dp.isOptionalCodecsEnabled(activeDevice)
== BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED;
((SwitchPreference) mPreference).setChecked(isEnabled);
}
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
index 8e6158b..08d6ca4 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
@@ -737,7 +737,7 @@
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setMessage(getContext().getString(R.string.storage_detail_dialog_system,
- Build.VERSION.RELEASE))
+ Build.VERSION.RELEASE_OR_CODENAME))
.setPositiveButton(android.R.string.ok, null)
.create();
}
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
index 3f93303..d6cf442 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
@@ -75,7 +75,7 @@
@Override
public CharSequence getSummary() {
- return Build.VERSION.RELEASE;
+ return Build.VERSION.RELEASE_OR_CODENAME;
}
@Override
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java
index a63c206..eefa1f9 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java
@@ -34,6 +34,6 @@
@Override
public CharSequence getSummary() {
- return Build.VERSION.RELEASE;
+ return Build.VERSION.RELEASE_OR_CODENAME;
}
}
diff --git a/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java b/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java
index d2310c3..170c699 100644
--- a/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java
+++ b/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java
@@ -24,12 +24,16 @@
import android.os.Bundle;
import android.service.notification.ConditionProviderService;
import android.util.Log;
+import android.view.View;
import android.widget.Toast;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.core.SubSettingLauncher;
public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase {
@@ -108,6 +112,12 @@
}
@Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ Utils.setActionBarShadowAnimation(getActivity(), getSettingsLifecycle(), getListView());
+ }
+
+ @Override
public int getHelpResource() {
return R.string.help_uri_interruptions;
}
diff --git a/src/com/android/settings/system/SystemUpdatePreferenceController.java b/src/com/android/settings/system/SystemUpdatePreferenceController.java
index 38a88b9..92819d6 100644
--- a/src/com/android/settings/system/SystemUpdatePreferenceController.java
+++ b/src/com/android/settings/system/SystemUpdatePreferenceController.java
@@ -89,7 +89,7 @@
@Override
public CharSequence getSummary() {
CharSequence summary = mContext.getString(R.string.android_version_summary,
- Build.VERSION.RELEASE);
+ Build.VERSION.RELEASE_OR_CODENAME);
final FutureTask<Bundle> bundleFutureTask = new FutureTask<>(
// Put the API call in a future to avoid StrictMode violation.
() -> mUpdateManager.retrieveSystemUpdateInfo());
diff --git a/src/com/android/settings/widget/EntityHeaderController.java b/src/com/android/settings/widget/EntityHeaderController.java
index 8e31290..440882f 100644
--- a/src/com/android/settings/widget/EntityHeaderController.java
+++ b/src/com/android/settings/widget/EntityHeaderController.java
@@ -29,7 +29,6 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.text.TextUtils;
-import android.util.IconDrawableFactory;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -147,7 +146,7 @@
* accessibility purposes.
*/
public EntityHeaderController setIcon(ApplicationsState.AppEntry appEntry) {
- mIcon = IconDrawableFactory.newInstance(mAppContext).getBadgedIcon(appEntry.info);
+ mIcon = Utils.getBadgedIcon(mAppContext, appEntry.info);
return this;
}
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 64814fa..9d075a7 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -1020,8 +1020,7 @@
final Context context = getContext();
final PowerManager powerManager = context.getSystemService(PowerManager.class);
final ContentResolver contentResolver = context.getContentResolver();
- return Settings.Global.getInt(contentResolver,
- Settings.Global.WIFI_WAKEUP_ENABLED, 0) == 1
+ return mWifiManager.isAutoWakeupEnabled()
&& Settings.Global.getInt(contentResolver,
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1
&& Settings.Global.getInt(contentResolver,
diff --git a/src/com/android/settings/wifi/WifiSettings2.java b/src/com/android/settings/wifi/WifiSettings2.java
index 1a7d572..86effea 100644
--- a/src/com/android/settings/wifi/WifiSettings2.java
+++ b/src/com/android/settings/wifi/WifiSettings2.java
@@ -851,8 +851,7 @@
final Context context = getContext();
final PowerManager powerManager = context.getSystemService(PowerManager.class);
final ContentResolver contentResolver = context.getContentResolver();
- return Settings.Global.getInt(contentResolver,
- Settings.Global.WIFI_WAKEUP_ENABLED, 0) == 1
+ return mWifiManager.isAutoWakeupEnabled()
&& Settings.Global.getInt(contentResolver,
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1
&& Settings.Global.getInt(contentResolver,
diff --git a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
index 855b329..d2a4a98 100644
--- a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
@@ -24,6 +24,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.location.LocationManager;
+import android.net.wifi.WifiManager;
import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
@@ -57,6 +58,9 @@
@VisibleForTesting
LocationManager mLocationManager;
+ @VisibleForTesting
+ WifiManager mWifiManager;
+
private final BroadcastReceiver mLocationReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -70,6 +74,7 @@
public WifiWakeupPreferenceController(Context context) {
super(context, KEY_ENABLE_WIFI_WAKEUP);
mLocationManager = (LocationManager) context.getSystemService(Service.LOCATION_SERVICE);
+ mWifiManager = context.getSystemService(WifiManager.class);
}
public void setFragment(Fragment hostFragment) {
@@ -160,13 +165,11 @@
}
private boolean getWifiWakeupEnabled() {
- return Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.WIFI_WAKEUP_ENABLED, 0) == 1;
+ return mWifiManager.isAutoWakeupEnabled();
}
private void setWifiWakeupEnabled(boolean enabled) {
- Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.WIFI_WAKEUP_ENABLED,
- enabled ? 1 : 0);
+ mWifiManager.setAutoWakeupEnabled(enabled);
}
@Override
diff --git a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
index b9e39bc..f1cb2f3 100644
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
@@ -904,7 +904,14 @@
*/
@Override
public void onDisconnectResult(@DisconnectStatus int status) {
- if (status != DisconnectCallback.DISCONNECT_STATUS_SUCCESS) {
+ if (status == DisconnectCallback.DISCONNECT_STATUS_SUCCESS) {
+ final Activity activity = mFragment.getActivity();
+ if (activity != null) {
+ Toast.makeText(activity,
+ activity.getString(R.string.wifi_disconnected_from, mWifiEntry.getTitle()),
+ Toast.LENGTH_SHORT).show();
+ }
+ } else {
Log.e(TAG, "Disconnect Wi-Fi network failed");
}
}
diff --git a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
index 3a571d7..8a4be10 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
@@ -39,12 +39,10 @@
private String[] mBandEntries;
private String[] mBandSummaries;
private int mBandIndex;
- private boolean isDualMode;
public WifiTetherApBandPreferenceController(Context context,
OnTetherConfigUpdateListener listener) {
super(context, listener);
- isDualMode = mWifiManager.isStaApConcurrencySupported();
updatePreferenceEntries();
}
@@ -106,16 +104,12 @@
private int validateSelection(int band) {
// unsupported states:
- // 1: no dual mode means we can't have multiband - default to 5GHZ
+ // 1: BAND_5GHZ only - include 2GHZ since some of countries doesn't support 5G hotspot
// 2: no 5 GHZ support means we can't have BAND_5GHZ - default to 2GHZ
- // 3: With Dual mode support we can't have BAND_5GHZ only - include 2GHZ
- if (!isDualMode
- && ((band & SoftApConfiguration.BAND_5GHZ) != 0)
- && ((band & SoftApConfiguration.BAND_2GHZ) != 0)) {
- return SoftApConfiguration.BAND_5GHZ;
- } else if (!is5GhzBandSupported() && SoftApConfiguration.BAND_5GHZ == band) {
- return SoftApConfiguration.BAND_2GHZ;
- } else if (isDualMode && SoftApConfiguration.BAND_5GHZ == band) {
+ if (SoftApConfiguration.BAND_5GHZ == band) {
+ if (!is5GhzBandSupported()) {
+ return SoftApConfiguration.BAND_2GHZ;
+ }
return SoftApConfiguration.BAND_5GHZ | SoftApConfiguration.BAND_2GHZ;
}
@@ -125,13 +119,8 @@
@VisibleForTesting
void updatePreferenceEntries() {
Resources res = mContext.getResources();
- int entriesRes = R.array.wifi_ap_band_config_full;
- int summariesRes = R.array.wifi_ap_band_summary_full;
- // change the list options if this is a dual mode device
- if (isDualMode) {
- entriesRes = R.array.wifi_ap_band_dual_mode;
- summariesRes = R.array.wifi_ap_band_dual_mode_summary;
- }
+ int entriesRes = R.array.wifi_ap_band;
+ int summariesRes = R.array.wifi_ap_band_summary;
mBandEntries = res.getStringArray(entriesRes);
mBandSummaries = res.getStringArray(summariesRes);
}
diff --git a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
index 1f63c9c4..a161f84 100644
--- a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
@@ -39,6 +39,7 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
+import com.android.settings.testutils.shadow.ShadowSettingsLibUtils;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.applications.AppUtils;
import com.android.settingslib.applications.ApplicationsState;
@@ -58,7 +59,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowEntityHeaderController.class)
+@Config(shadows = {ShadowEntityHeaderController.class, ShadowSettingsLibUtils.class})
public class AppInfoWithHeaderTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java
index f0fdc9c..dfa9383 100644
--- a/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java
@@ -16,8 +16,6 @@
package com.android.settings.applications;
-import static com.android.settings.applications.AppPermissionsPreferenceController.NUM_PERMISSIONS_TO_SHOW;
-
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
@@ -75,7 +73,7 @@
public void updateSummary_noGrantedPermission_shouldSetNoPermissionGrantedSummary() {
doNothing().when(mController).queryPermissionSummary();
mController.updateState(mPreference);
- mController.mNumPackageChecked = 2;
+ mController.mNumPackageChecked = 3;
mController.updateSummary(new ArrayList<>());
@@ -84,14 +82,14 @@
}
@Test
- public void updateSummary_hasPermissionGroups_shouldSetPermissionAsSummary() {
+ public void updateSummary_hasOnePermission_shouldSetPermissionAsSummary() {
doNothing().when(mController).queryPermissionSummary();
mController.updateState(mPreference);
final String permission = "location";
final ArrayList<CharSequence> labels = new ArrayList<>();
labels.add(permission);
final String summary = "Apps using " + permission;
- mController.mNumPackageChecked = 2;
+ mController.mNumPackageChecked = 3;
mController.updateSummary(labels);
@@ -99,6 +97,41 @@
}
@Test
+ public void updateSummary_hasThreePermissions_shouldShowThreePermissionAsSummary() {
+ doNothing().when(mController).queryPermissionSummary();
+ mController.updateState(mPreference);
+ mController.mNumPackageChecked = 3;
+ final List<CharSequence> labels = new ArrayList<>();
+ labels.add("Phone");
+ labels.add("SMS");
+ labels.add("Microphone");
+
+ mController.updateSummary(labels);
+
+ final String summary = "Apps using microphone, sms, and phone";
+ assertThat(mPreference.getSummary()).isEqualTo(summary);
+ }
+
+ @Test
+ public void updateSummary_hasFivePermissions_shouldShowThreePermissionsAndMoreAsSummary() {
+ doNothing().when(mController).queryPermissionSummary();
+ mController.updateState(mPreference);
+ mController.mNumPackageChecked = 3;
+ final List<CharSequence> labels = new ArrayList<>();
+ labels.add("Phone");
+ labels.add("SMS");
+ labels.add("Microphone");
+ labels.add("Contacts");
+ labels.add("Camera");
+ labels.add("Location");
+
+ mController.updateSummary(labels);
+
+ final String summary = "Apps using microphone, contacts, and sms, and more";
+ assertThat(mPreference.getSummary()).isEqualTo(summary);
+ }
+
+ @Test
public void updateSummary_notReachCallbackCount_shouldNotSetSummary() {
doNothing().when(mController).queryPermissionSummary();
mController.updateState(mPreference);
@@ -110,29 +143,4 @@
verify(mPreference, never()).setSummary(anyString());
}
-
- @Test
- public void updateSummary_hasFiveItems_shouldShowCertainNumItems() {
- doNothing().when(mController).queryPermissionSummary();
- mController.updateState(mPreference);
- mController.mNumPackageChecked = 2;
-
- mController.updateSummary(getPermissionGroupsSet());
-
- final CharSequence summary = mPreference.getSummary();
- final int items = summary.toString().split(",").length;
- assertThat(items).isEqualTo(NUM_PERMISSIONS_TO_SHOW);
- }
-
- private List<CharSequence> getPermissionGroupsSet() {
- final List<CharSequence> labels = new ArrayList<>();
- labels.add("Phone");
- labels.add("SMS");
- labels.add("Microphone");
- labels.add("Contacts");
- labels.add("Camera");
- labels.add("Location");
-
- return labels;
- }
}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
index c82cbe5..6684e1a 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
@@ -42,6 +42,7 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.testutils.shadow.ShadowSettingsLibUtils;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.widget.LayoutPreference;
@@ -54,8 +55,10 @@
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
+@Config(shadows = ShadowSettingsLibUtils.class)
public class AppHeaderViewPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java
index 802f871..7ff179e 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java
@@ -103,13 +103,15 @@
@Test
public void onIndexUpdated_checkFlow() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
when(mBluetoothA2dpConfigStore.createCodecConfig()).thenReturn(mCodecConfigAAC);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.onIndexUpdated(mCurrentConfig);
verify(mController).writeConfigurationValues(mCurrentConfig);
- verify(mBluetoothA2dp).setCodecConfigPreference(null, mCodecConfigAAC);
+ verify(mBluetoothA2dp).setCodecConfigPreference(
+ mBluetoothA2dp.getActiveDevice(), mCodecConfigAAC);
assertThat(mPreference.getSummary()).isEqualTo(SUMMARY);
}
@@ -134,14 +136,15 @@
assertThat(mController.getCurrentCodecConfig()).isNull();
mController.onBluetoothServiceConnected(mBluetoothA2dp);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(null);
+ when(mBluetoothA2dp.getCodecStatus(mBluetoothA2dp.getActiveDevice())).thenReturn(null);
assertThat(mController.getCurrentCodecConfig()).isNull();
}
@Test
public void getCurrentCodecConfig_verifyConfig() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
assertThat(mController.getCurrentCodecConfig()).isEqualTo(mCodecConfigAAC);
@@ -150,7 +153,8 @@
@Test
public void getSelectableConfigs_verifyConfig() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
assertThat(mController.getSelectableConfigs(null)).isEqualTo(mCodecConfigs);
@@ -159,7 +163,8 @@
@Test
public void getSelectableByCodecType_verifyConfig() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
assertThat(mController.getSelectableByCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC))
@@ -169,7 +174,8 @@
@Test
public void getSelectableByCodecType_unavailable() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
assertThat(mController.getSelectableByCodecType(
@@ -179,7 +185,8 @@
@Test
public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
verify(mBluetoothA2dpConfigStore).setCodecType(mCodecConfigAAC.getCodecType());
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java
index 0061fc0..7c5e86e 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java
@@ -92,7 +92,8 @@
public void writeConfigurationValues_selectDefault_setHighest() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(0);
@@ -121,7 +122,8 @@
public void getSelectableIndex_verifyList() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
List<Integer> indexList = new ArrayList<>();
indexList.add(mPreference.getDefaultIndex());
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java
index 326cc22..32651ba 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java
@@ -92,7 +92,8 @@
public void writeConfigurationValues_selectDefault_setHighest() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(0);
@@ -118,7 +119,8 @@
public void getSelectableIndex_verifyList() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
List<Integer> indexList = new ArrayList<>();
indexList.add(mPreference.getDefaultIndex());
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java
index f4ed811..f93766f 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java
@@ -99,7 +99,8 @@
public void writeConfigurationValues_selectDefault_setHighest() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(0);
@@ -111,7 +112,8 @@
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(1);
@@ -138,7 +140,8 @@
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(2);
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceControllerTest.java
index 1f0daa3..0701e78 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceControllerTest.java
@@ -91,7 +91,7 @@
@Test
public void updateState_codecSupported_setEnable() {
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
- when(mBluetoothA2dp.supportsOptionalCodecs(mActiveDevice)).thenReturn(
+ when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
@@ -102,7 +102,7 @@
@Test
public void updateState_codecNotSupported_setDisable() {
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
- when(mBluetoothA2dp.supportsOptionalCodecs(mActiveDevice)).thenReturn(
+ when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
mBluetoothA2dp.OPTIONAL_CODECS_NOT_SUPPORTED);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
@@ -113,9 +113,9 @@
@Test
public void updateState_codecSupportedAndEnabled_checked() {
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
- when(mBluetoothA2dp.supportsOptionalCodecs(mActiveDevice)).thenReturn(
+ when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
- when(mBluetoothA2dp.getOptionalCodecsEnabled(mActiveDevice)).thenReturn(
+ when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
mBluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
@@ -126,9 +126,9 @@
@Test
public void updateState_codecSupportedAndDisabled_notChecked() {
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
- when(mBluetoothA2dp.supportsOptionalCodecs(mActiveDevice)).thenReturn(
+ when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
- when(mBluetoothA2dp.getOptionalCodecsEnabled(mActiveDevice)).thenReturn(
+ when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
mBluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java
index 35bd704..30e3f31 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java
@@ -110,7 +110,8 @@
public void updateState_codeTypeIsLDAC_enablePreference() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigLDAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
@@ -121,7 +122,8 @@
public void updateState_codeTypeAAC_disablePreference() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
index d274a57..089acc5 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
@@ -93,7 +93,8 @@
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC);
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(0);
@@ -125,7 +126,8 @@
public void getSelectableIndex_verifyList() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(
+ mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
List<Integer> indexList = new ArrayList<>();
indexList.add(mController.getDefaultIndex());
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceControllerTest.java
index a3606e8..9fca65d 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceControllerTest.java
@@ -63,7 +63,7 @@
@Test
public void getSummary_shouldGetBuildVersion() {
- assertThat(mController.getSummary()).isEqualTo(Build.VERSION.RELEASE);
+ assertThat(mController.getSummary()).isEqualTo(Build.VERSION.RELEASE_OR_CODENAME);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java
index d000c91..903b88b 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java
@@ -65,6 +65,6 @@
public void updatePreference_shouldSetSummaryToBuildNumber() {
mController.updateState(mPreference);
- assertThat(mPreference.getSummary()).isEqualTo(Build.VERSION.RELEASE);
+ assertThat(mPreference.getSummary()).isEqualTo(Build.VERSION.RELEASE_OR_CODENAME);
}
}
diff --git a/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java
index fbd87c9..95c95bb 100644
--- a/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java
@@ -139,7 +139,7 @@
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.android_version_summary,
- Build.VERSION.RELEASE));
+ Build.VERSION.RELEASE_OR_CODENAME));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSettingsLibUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSettingsLibUtils.java
new file mode 100644
index 0000000..2fce5ad
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSettingsLibUtils.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2020 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.testutils.shadow;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+
+import com.android.settingslib.Utils;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+@Implements(Utils.class)
+public class ShadowSettingsLibUtils {
+
+ @Implementation
+ protected static Drawable getBadgedIcon(Context context, ApplicationInfo appInfo) {
+ return new ColorDrawable(0);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
index c1f33c6..eadd33a 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
@@ -18,7 +18,10 @@
import android.content.ComponentName;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
import android.hardware.fingerprint.FingerprintManager;
import android.os.UserHandle;
import android.os.UserManager;
@@ -144,6 +147,11 @@
return sResultLinks;
}
+ @Implementation
+ protected static Drawable getBadgedIcon(Context context, ApplicationInfo appInfo) {
+ return new ColorDrawable(0);
+ }
+
public static void setHandledDomains(ArraySet<String> links) {
sResultLinks = links;
}
diff --git a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
index 1d600a4..df9a2c1 100644
--- a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
@@ -30,7 +30,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
-import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.ColorDrawable;
@@ -38,7 +37,6 @@
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
-import android.widget.ImageView;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
@@ -46,7 +44,6 @@
import androidx.preference.Preference;
import com.android.settings.R;
-import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.widget.LayoutPreference;
import org.junit.Before;
@@ -258,20 +255,6 @@
}
@Test
- public void setIcon_usingAppEntry_shouldLoadIconFromDrawableFactory() {
- final View view = mLayoutInflater
- .inflate(R.layout.settings_entity_header, null /* root */);
- final ApplicationsState.AppEntry entry = mock(ApplicationsState.AppEntry.class);
- entry.info = new ApplicationInfo();
- mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
- mController.setIcon(entry).done(mActivity);
- final ImageView iconView = view.findViewById(R.id.entity_header_icon);
-
- // ... entry.icon is still empty. This means the icon didn't come from cache.
- assertThat(entry.icon).isNull();
- }
-
- @Test
public void bindButton_hasAppNotifIntent_shouldShowButton() {
final View appLinks = mLayoutInflater
.inflate(R.layout.settings_entity_header, null /* root */);
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
index 320d767..e5b5eb1 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
@@ -33,6 +33,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
+import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.UserManager;
@@ -71,6 +72,8 @@
@Mock
private PowerManager mPowerManager;
@Mock
+ private WifiManager mWifiManager;
+ @Mock
private DataUsagePreference mDataUsagePreference;
private Context mContext;
private WifiSettings2 mWifiSettings2;
@@ -85,10 +88,12 @@
mWifiSettings2 = spy(new WifiSettings2());
doReturn(mContext).when(mWifiSettings2).getContext();
doReturn(mPowerManager).when(mContext).getSystemService(PowerManager.class);
+ doReturn(mWifiManager).when(mContext).getSystemService(WifiManager.class);
mWifiSettings2.mAddWifiNetworkPreference = new AddWifiNetworkPreference(mContext);
mWifiSettings2.mSavedNetworksPreference = new Preference(mContext);
mWifiSettings2.mConfigureWifiSettingsPreference = new Preference(mContext);
mWifiSettings2.mWifiPickerTracker = mMockWifiPickerTracker;
+ mWifiSettings2.mWifiManager = mWifiManager;
}
@Test
@@ -157,7 +162,7 @@
@Test
public void setAdditionalSettingsSummaries_wifiWakeupEnabled_displayOn() {
final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putInt(contentResolver, Settings.Global.WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
Settings.Global.putInt(contentResolver, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 1);
Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0);
when(mPowerManager.isPowerSaveMode()).thenReturn(false);
@@ -171,7 +176,7 @@
@Test
public void setAdditionalSettingsSummaries_wifiWakeupDisabled_displayOff() {
final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putInt(contentResolver, Settings.Global.WIFI_WAKEUP_ENABLED, 0);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(false);
mWifiSettings2.setAdditionalSettingsSummaries();
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
index 5145cc1..0ae3465 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
@@ -32,9 +32,11 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
+import android.net.wifi.EAPConstants;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.net.wifi.hotspot2.PasspointConfiguration;
+import android.net.wifi.hotspot2.pps.Credential;
import android.net.wifi.hotspot2.pps.HomeSp;
import android.os.Bundle;
import android.os.PowerManager;
@@ -124,6 +126,13 @@
sp.setFqdn("fqdn");
final PasspointConfiguration config = new PasspointConfiguration();
config.setHomeSp(sp);
+ Credential.SimCredential simCredential = new Credential.SimCredential();
+ Credential credential = new Credential();
+ credential.setRealm("test.example.com");
+ simCredential.setImsi("12345*");
+ simCredential.setEapType(EAPConstants.EAP_SIM);
+ credential.setSimCredential(simCredential);
+ config.setCredential(credential);
mockConfigs.add(config);
}
return mockConfigs;
@@ -186,7 +195,7 @@
@Test
public void setAdditionalSettingsSummaries_wifiWakeupEnabled_displayOn() {
final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putInt(contentResolver, Settings.Global.WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
Settings.Global.putInt(contentResolver, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 1);
Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0);
when(mPowerManager.isPowerSaveMode()).thenReturn(false);
@@ -200,7 +209,7 @@
@Test
public void setAdditionalSettingsSummaries_wifiWakeupDisabled_displayOff() {
final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putInt(contentResolver, Settings.Global.WIFI_WAKEUP_ENABLED, 0);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(false);
mWifiSettings.setAdditionalSettingsSummaries();
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java
index 4266c84..a41d7c8 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java
@@ -17,15 +17,17 @@
package com.android.settings.wifi;
import static android.provider.Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE;
-import static android.provider.Settings.Global.WIFI_WAKEUP_ENABLED;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.content.Context;
import android.location.LocationManager;
+import android.net.wifi.WifiManager;
import android.provider.Settings;
import android.text.TextUtils;
@@ -53,6 +55,8 @@
@Mock
private LocationManager mLocationManager;
@Mock
+ private WifiManager mWifiManager;
+ @Mock
private SwitchPreference mPreference;
@Before
@@ -63,6 +67,7 @@
mController.setFragment(mFragment);
mController.mLocationManager = mLocationManager;
mController.mPreference = mPreference;
+ mController.mWifiManager = mWifiManager;
Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 1);
doReturn(true).when(mLocationManager).isLocationEnabled();
@@ -70,20 +75,19 @@
@Test
public void setChecked_scanEnableLocationEnable_wifiWakeupEnable() {
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(false);
Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 1);
doReturn(true).when(mLocationManager).isLocationEnabled();
mController.setChecked(true);
- assertThat(Settings.Global.getInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0))
- .isEqualTo(1);
+ verify(mWifiManager).setAutoWakeupEnabled(true);
}
@Test
public void updateState_wifiWakeupEnableScanningDisable_wifiWakeupDisabled() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 0);
doReturn(true).when(mLocationManager).isLocationEnabled();
@@ -97,7 +101,7 @@
@Test
public void updateState_preferenceSetCheckedWhenWakeupSettingEnabled() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 1);
doReturn(true).when(mLocationManager).isLocationEnabled();
@@ -111,7 +115,7 @@
@Test
public void updateState_preferenceSetUncheckedWhenWakeupSettingDisabled() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(false);
mController.updateState(preference);
@@ -123,7 +127,7 @@
@Test
public void updateState_preferenceSetUncheckedWhenWifiScanningDisabled() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 0);
mController.updateState(preference);
@@ -134,7 +138,7 @@
@Test
public void updateState_preferenceSetUncheckedWhenWakeupSettingEnabledNoLocation() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
doReturn(false).when(mLocationManager).isLocationEnabled();
mController.updateState(preference);
@@ -147,7 +151,7 @@
@Test
public void updateState_preferenceSetUncheckedWhenWakeupSettingDisabledLocationEnabled() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(false);
doReturn(false).when(mLocationManager).isLocationEnabled();
mController.updateState(preference);
@@ -160,7 +164,7 @@
@Test
public void updateState_preferenceSetUncheckedWhenWifiScanningDisabledLocationEnabled() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 0);
doReturn(false).when(mLocationManager).isLocationEnabled();
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
index b28498b..74f94e9 100644
--- a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
@@ -25,9 +25,11 @@
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.net.wifi.EAPConstants;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.net.wifi.hotspot2.PasspointConfiguration;
+import android.net.wifi.hotspot2.pps.Credential;
import android.net.wifi.hotspot2.pps.HomeSp;
import androidx.preference.PreferenceCategory;
@@ -35,7 +37,6 @@
import com.android.settings.testutils.shadow.ShadowAccessPoint;
import com.android.settings.testutils.shadow.ShadowWifiManager;
-import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.AccessPointPreference;
import org.junit.Before;
@@ -111,6 +112,13 @@
homeSp.setFqdn("FQDN");
homeSp.setFriendlyName("TESTPASSPOINT");
config.setHomeSp(homeSp);
+ final Credential.SimCredential simCredential = new Credential.SimCredential();
+ final Credential credential = new Credential();
+ credential.setRealm("test.example.com");
+ simCredential.setImsi("12345*");
+ simCredential.setEapType(EAPConstants.EAP_SIM);
+ credential.setSimCredential(simCredential);
+ config.setCredential(credential);
return config;
}
}
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
index b5645b4..32cec68 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
@@ -81,7 +81,6 @@
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
when(mWifiManager.getSoftApConfiguration()).thenReturn(
new SoftApConfiguration.Builder().build());
- when(mWifiManager.isStaApConcurrencySupported()).thenReturn(false);
mController = new WifiTetherApBandPreferenceController(mContext, mListener);
}
@@ -90,9 +89,8 @@
public void display_5GhzSupported_shouldDisplayFullList() {
when(mWifiManager.getCountryCode()).thenReturn("US");
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
- when(mWifiManager.isStaApConcurrencySupported()).thenReturn(true);
- // Create a new instance to pick the proper value of isDualModeSupported()
+ // Create a new instance
mController = new WifiTetherApBandPreferenceController(mContext, mListener);
mController.displayPreference(mScreen);
@@ -126,38 +124,10 @@
}
@Test
- public void changePreference_noDualModeWith5G_shouldUpdateValue() {
+ public void changePreference_With5G_shouldUpdateValue() {
when(mWifiManager.getCountryCode()).thenReturn("US");
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
- mController.displayPreference(mScreen);
-
- // 'Auto' option should be prevented from being set since
- // it is invalid for this configuration
- mController.onPreferenceChange(mPreference, VAL_2_5_GHZ_STR);
- assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
- assertThat(mPreference.getSummary()).isEqualTo(FIVE_GHZ_STRING);
- verify(mListener, times(1)).onTetherConfigUpdated(mController);
-
- // set to 5 Ghz
- mController.onPreferenceChange(mPreference, VAL_5GHZ_STR);
- assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
- assertThat(mPreference.getSummary()).isEqualTo(FIVE_GHZ_STRING);
- verify(mListener, times(2)).onTetherConfigUpdated(mController);
-
- // set to 2 Ghz
- mController.onPreferenceChange(mPreference, VAL_2GHZ_STR);
- assertThat(mController.getBandIndex()).isEqualTo(VAL_2GHZ_INT);
- assertThat(mPreference.getSummary()).isEqualTo(TWO_GHZ_STRING);
- verify(mListener, times(3)).onTetherConfigUpdated(mController);
- }
-
- @Test
- public void changePreference_dualModeWith5G_shouldUpdateValue() {
- when(mWifiManager.getCountryCode()).thenReturn("US");
- when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
- when(mWifiManager.isStaApConcurrencySupported()).thenReturn(true);
-
// Create a new instance to pick the proper value of isDualModeSupported()
mController = new WifiTetherApBandPreferenceController(mContext, mListener);