Merge "Update FSI permission strings" into udc-dev
diff --git a/res/layout/accessibility_launch_activity_preference.xml b/res/layout/accessibility_launch_activity_preference.xml
index 5ec6bea..6791206 100644
--- a/res/layout/accessibility_launch_activity_preference.xml
+++ b/res/layout/accessibility_launch_activity_preference.xml
@@ -34,7 +34,7 @@
<TextView
android:id="@android:id/title"
android:layout_height="wrap_content"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_gravity="center_vertical"
android:paddingVertical="@dimen/settingslib_switch_title_margin"
android:ellipsize="end"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 14e869e..4f67a35 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -361,7 +361,7 @@
<string name="desc_app_locale_disclaimer">Language may differ from languages available in the app. Some apps may not support this setting.</string>
<!-- Description for introduction of the locale selection supported of app list [CHAR LIMIT=NONE]-->
- <string name="desc_app_locale_selection_supported">Only apps that support language selection are shown here.</string>
+ <string name="desc_app_locale_selection_supported">Set the language for each app.</string>
<!-- Description for the introduction to language picker activity. [CHAR LIMIT=NONE]-->
<string name="desc_introduction_of_language_picker">Your system, apps, and websites use the first supported language from your preferred languages.</string>
@@ -5164,7 +5164,7 @@
<!-- Title when early heads up is solved [CHAR LIMIT=NONE] -->
<string name="battery_tip_early_heads_up_done_title">Battery Saver on</string>
<!-- Accessibility description for battery saver learn more link [CHAR LIMIT=NONE] -->
- <string name="battery_saver_link_a11y">Learn more about Battery saver</string>
+ <string name="battery_saver_link_a11y">Learn more about Battery Saver</string>
<!-- Summary when early heads up is solved [CHAR LIMIT=NONE] -->
<string name="battery_tip_early_heads_up_done_summary">Some features may be limited</string>
<!-- Title for the battery high usage tip [CHAR LIMIT=NONE] -->
@@ -5472,9 +5472,9 @@
<!-- [CHAR_LIMIT=NONE] Device screen on time category for a selected slot -->
<string name="screen_time_category_for_slot">Screen time for <xliff:g id="slot">%s</xliff:g></string>
<!-- [CHAR_LIMIT=NONE] The spinner item text in the battery usage breakdown. -->
- <string name="battery_usage_spinner_by_apps">By apps</string>
+ <string name="battery_usage_spinner_view_by_apps">View by apps</string>
<!-- [CHAR_LIMIT=NONE] The spinner item text in the battery usage breakdown. -->
- <string name="battery_usage_spinner_by_systems">By systems</string>
+ <string name="battery_usage_spinner_view_by_systems">View by systems</string>
<!-- [CHAR_LIMIT=NONE] Less than some percentage, e.g. < 1% -->
<string name="battery_usage_less_than_percent">< <xliff:g id="percentage">%1$s</xliff:g></string>
<!-- Process Stats strings -->
diff --git a/src/com/android/settings/applications/AppStateLocaleBridge.java b/src/com/android/settings/applications/AppStateLocaleBridge.java
index 2fea004..a50d617 100644
--- a/src/com/android/settings/applications/AppStateLocaleBridge.java
+++ b/src/com/android/settings/applications/AppStateLocaleBridge.java
@@ -83,7 +83,7 @@
Log.d(TAG, "[" + entry.info.packageName + "]" + " has No extra info.");
return false;
}
- return (Boolean) entry.extraInfo;
+ return entry.extraInfo == Boolean.TRUE;
}
};
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
index c627df3..f19fb91 100644
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
@@ -23,6 +23,7 @@
import android.app.Activity;
import android.app.Dialog;
import android.content.ComponentName;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -33,9 +34,11 @@
import android.credentials.CredentialManager;
import android.credentials.CredentialProviderInfo;
import android.credentials.SetEnabledProvidersException;
+import android.database.ContentObserver;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Handler;
import android.os.OutcomeReceiver;
import android.os.UserHandle;
import android.provider.DeviceConfig;
@@ -59,10 +62,12 @@
import androidx.preference.SwitchPreference;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.content.PackageMonitor;
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.settingslib.utils.ThreadUtils;
import java.util.ArrayList;
import java.util.HashMap;
@@ -89,10 +94,12 @@
private final Executor mExecutor;
private final Map<String, SwitchPreference> mPrefs = new HashMap<>(); // key is package name
private final List<ServiceInfo> mPendingServiceInfos = new ArrayList<>();
+ private final Handler mHandler = new Handler();
private @Nullable FragmentManager mFragmentManager = null;
private @Nullable Delegate mDelegate = null;
private @Nullable String mFlagOverrideForTest = null;
+ private @Nullable PreferenceScreen mPreferenceScreen = null;
public CredentialManagerPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
@@ -103,6 +110,7 @@
mExecutor = ContextCompat.getMainExecutor(mContext);
mCredentialManager =
getCredentialManager(context, preferenceKey.equals("credentials_test"));
+ new SettingContentObserver(mHandler).register(context.getContentResolver());
}
private @Nullable CredentialManager getCredentialManager(Context context, boolean isTest) {
@@ -241,6 +249,25 @@
update();
}
+ private void update() {
+ if (mCredentialManager == null) {
+ return;
+ }
+
+ setAvailableServices(
+ mCredentialManager.getCredentialProviderServices(
+ getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY),
+ null);
+ }
+
+ private void updateFromExternal() {
+ update();
+
+ if (mPreferenceScreen != null) {
+ displayPreference(mPreferenceScreen);
+ }
+ }
+
@VisibleForTesting
void setAvailableServices(
List<CredentialProviderInfo> availableServices,
@@ -276,6 +303,7 @@
// Since the UI is being cleared, clear any refs.
mPrefs.clear();
+ mPreferenceScreen = screen;
PreferenceGroup group = screen.findPreference(getPreferenceKey());
Context context = screen.getContext();
mPrefs.putAll(buildPreferenceList(context, group));
@@ -348,6 +376,10 @@
Map<String, List<CredentialProviderInfo>> groupedInfos = new HashMap<>();
for (CredentialProviderInfo cpi : mServices) {
String packageName = cpi.getServiceInfo().packageName;
+ if (isProviderHiddenBecauseOfAutofill(packageName)) {
+ continue;
+ }
+
if (!groupedInfos.containsKey(packageName)) {
groupedInfos.put(packageName, new ArrayList<>());
}
@@ -551,6 +583,23 @@
return new NewProviderConfirmationDialogFragment(host, packageName, appName);
}
+ /** If the provider is also the autofill provider then hide it. */
+ @VisibleForTesting
+ public boolean isProviderHiddenBecauseOfAutofill(String packageName) {
+ final String autofillService = Settings.Secure.getStringForUser(
+ mContext.getContentResolver(),
+ Settings.Secure.AUTOFILL_SERVICE,
+ getUser());
+ if (autofillService == null || TextUtils.isEmpty(autofillService)) {
+ return false;
+ }
+ if (packageName == null || TextUtils.isEmpty(packageName)) {
+ return false;
+ }
+
+ return autofillService.startsWith(packageName);
+ }
+
@VisibleForTesting
void completeEnableProviderDialogBox(
int whichButton, String packageName, boolean setActivityResult) {
@@ -655,20 +704,6 @@
}
};
- /**
- * Update the data in this UI.
- */
- private void update() {
- if (mCredentialManager == null) {
- return;
- }
-
- setAvailableServices(
- mCredentialManager.getCredentialProviderServices(
- getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY),
- null);
- }
-
/** Dialog fragment parent class. */
private abstract static class CredentialManagerDialogFragment extends DialogFragment
implements DialogInterface.OnClickListener {
@@ -790,4 +825,28 @@
getDialogHost().onDialogClick(which);
}
}
+
+ /** Updates the list if setting content changes. */
+ private final class SettingContentObserver extends ContentObserver {
+
+ private final Uri mAutofillService =
+ Settings.Secure.getUriFor(Settings.Secure.AUTOFILL_SERVICE);
+
+ private final Uri mCredentialService =
+ Settings.Secure.getUriFor(Settings.Secure.CREDENTIAL_SERVICE);
+
+ public SettingContentObserver(Handler handler) {
+ super(handler);
+ }
+
+ public void register(ContentResolver contentResolver) {
+ contentResolver.registerContentObserver(mAutofillService, false, this, getUser());
+ contentResolver.registerContentObserver(mCredentialService, false, this, getUser());
+ }
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ updateFromExternal();
+ }
+ }
}
diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java
index 483e46a..de49ce1 100644
--- a/src/com/android/settings/bluetooth/BluetoothEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java
@@ -223,7 +223,6 @@
mSwitchController.setDisabledByAdmin(admin);
if (admin != null) {
mSwitchController.setChecked(false);
- mSwitchController.setEnabled(false);
}
return admin != null;
}
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java
index c272a49..b262dee 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java
@@ -177,8 +177,8 @@
mAppListPreferenceGroup.setOrderingAsAdded(false);
mSpinnerPreference.initializeSpinner(
new String[]{
- mPrefContext.getString(R.string.battery_usage_spinner_by_apps),
- mPrefContext.getString(R.string.battery_usage_spinner_by_systems)
+ mPrefContext.getString(R.string.battery_usage_spinner_view_by_apps),
+ mPrefContext.getString(R.string.battery_usage_spinner_view_by_systems)
},
new AdapterView.OnItemSelectedListener() {
@Override
diff --git a/src/com/android/settings/location/LocationSwitchBarController.java b/src/com/android/settings/location/LocationSwitchBarController.java
index c84014f..b150b1d 100644
--- a/src/com/android/settings/location/LocationSwitchBarController.java
+++ b/src/com/android/settings/location/LocationSwitchBarController.java
@@ -15,6 +15,7 @@
import android.content.Context;
import android.os.UserHandle;
+import android.os.UserManager;
import android.widget.Switch;
import com.android.settings.widget.SettingsMainSwitchBar;
@@ -75,8 +76,12 @@
// only, it would be re-enabled again if the switch bar is not disabled.
if (!hasBaseUserRestriction && admin != null) {
mSwitchBar.setDisabledByAdmin(admin);
+ } else if (restricted) {
+ RestrictedLockUtils.EnforcedAdmin enforcedAdmin = RestrictedLockUtils.EnforcedAdmin
+ .createDefaultEnforcedAdminWithRestriction(UserManager.DISALLOW_SHARE_LOCATION);
+ mSwitchBar.setDisabledByAdmin(enforcedAdmin);
} else {
- mSwitchBar.setEnabled(!restricted);
+ mSwitchBar.setEnabled(true);
}
if (enabled != mSwitchBar.isChecked()) {
diff --git a/src/com/android/settings/widget/SettingsMainSwitchBar.java b/src/com/android/settings/widget/SettingsMainSwitchBar.java
index 5ad16d7..8b8a9ba 100644
--- a/src/com/android/settings/widget/SettingsMainSwitchBar.java
+++ b/src/com/android/settings/widget/SettingsMainSwitchBar.java
@@ -21,14 +21,12 @@
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
-import android.widget.ImageView;
import android.widget.Switch;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.widget.MainSwitchBar;
-import com.android.settingslib.widget.R;
/**
* A {@link MainSwitchBar} with a customized Switch and provides the metrics feature.
@@ -47,7 +45,6 @@
boolean onBeforeCheckedChanged(Switch switchView, boolean isChecked);
}
- private ImageView mRestrictedIcon;
private EnforcedAdmin mEnforcedAdmin;
private boolean mDisabledByAdmin;
@@ -74,14 +71,6 @@
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
addOnSwitchChangeListener((switchView, isChecked) -> logMetrics(isChecked));
-
- mRestrictedIcon = findViewById(R.id.restricted_icon);
- mRestrictedIcon.setOnClickListener((View v) -> {
- if (mDisabledByAdmin) {
- RestrictedLockUtils.sendShowAdminSupportDetailsIntent(context, mEnforcedAdmin);
- onRestrictedIconClick();
- }
- });
}
/**
@@ -95,12 +84,9 @@
mDisabledByAdmin = true;
mTextView.setEnabled(false);
mSwitch.setEnabled(false);
- mSwitch.setVisibility(View.GONE);
- mRestrictedIcon.setVisibility(View.VISIBLE);
} else {
mDisabledByAdmin = false;
mSwitch.setVisibility(View.VISIBLE);
- mRestrictedIcon.setVisibility(View.GONE);
setEnabled(isEnabled());
}
}
@@ -120,11 +106,12 @@
@Override
public boolean performClick() {
- return getDelegatingView().performClick();
- }
+ if (mDisabledByAdmin) {
+ performRestrictedClick();
+ return true;
+ }
- protected void onRestrictedIconClick() {
- mMetricsFeatureProvider.clicked(mMetricsCategory, "switch_bar|restricted");
+ return mSwitch.performClick();
}
@Override
@@ -157,11 +144,12 @@
mMetricsCategory = category;
}
- private View getDelegatingView() {
- return mDisabledByAdmin ? mRestrictedIcon : mSwitch;
- }
-
private void logMetrics(boolean isChecked) {
mMetricsFeatureProvider.changed(mMetricsCategory, "switch_bar", isChecked ? 1 : 0);
}
+
+ private void performRestrictedClick() {
+ RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), mEnforcedAdmin);
+ mMetricsFeatureProvider.clicked(mMetricsCategory, "switch_bar|restricted");
+ }
}
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSettings.java b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
index 2774be6..4ce59b9 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSettings.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
@@ -80,11 +80,14 @@
@VisibleForTesting
SettingsMainSwitchBar mMainSwitchBar;
private WifiTetherSwitchBarController mSwitchBarController;
- private WifiTetherSSIDPreferenceController mSSIDPreferenceController;
- private WifiTetherPasswordPreferenceController mPasswordPreferenceController;
+ @VisibleForTesting
+ WifiTetherSSIDPreferenceController mSSIDPreferenceController;
+ @VisibleForTesting
+ WifiTetherPasswordPreferenceController mPasswordPreferenceController;
private WifiTetherSecurityPreferenceController mSecurityPreferenceController;
private WifiTetherMaximizeCompatibilityPreferenceController mMaxCompatibilityPrefController;
- private WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController;
+ @VisibleForTesting
+ WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController;
private boolean mUnavailable;
private WifiRestriction mWifiRestriction;
@@ -269,10 +272,12 @@
setLoading(restarting, false);
}
- private SoftApConfiguration buildNewConfig() {
- SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder();
+ @VisibleForTesting
+ SoftApConfiguration buildNewConfig() {
+ SoftApConfiguration currentConfig = mWifiTetherViewModel.getSoftApConfiguration();
+ SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder(currentConfig);
int securityType = (mWifiTetherViewModel.isSpeedFeatureAvailable())
- ? mWifiTetherViewModel.getSoftApConfiguration().getSecurityType()
+ ? currentConfig.getSecurityType()
: mSecurityPreferenceController.getSecurityType();
configBuilder.setSsid(mSSIDPreferenceController.getSSID());
if (securityType != SoftApConfiguration.SECURITY_TYPE_OPEN) {
diff --git a/tests/robotests/src/com/android/settings/location/LocationSwitchBarControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationSwitchBarControllerTest.java
index 348f64d..50f618f 100644
--- a/tests/robotests/src/com/android/settings/location/LocationSwitchBarControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationSwitchBarControllerTest.java
@@ -23,6 +23,7 @@
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.os.UserManager;
import android.provider.Settings;
import android.widget.Switch;
@@ -109,13 +110,25 @@
}
@Test
+ public void onLocationModeChanged_Restricted_shouldDisableSwitchByAdmin() {
+ final RestrictedLockUtils.EnforcedAdmin admin = RestrictedLockUtils.EnforcedAdmin
+ .createDefaultEnforcedAdminWithRestriction(UserManager.DISALLOW_SHARE_LOCATION);
+ doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
+ doReturn(false).when(mEnabler).hasShareLocationRestriction(anyInt());
+
+ mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, true);
+
+ verify(mSwitchBar).setDisabledByAdmin(admin);
+ }
+
+ @Test
public void onLocationModeChanged_Restricted_shouldDisableSwitch() {
doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
doReturn(true).when(mEnabler).hasShareLocationRestriction(anyInt());
- mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, true);
+ mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
- verify(mSwitchBar).setEnabled(false);
+ verify(mSwitchBar).setEnabled(true);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchBarTest.java b/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchBarTest.java
new file mode 100644
index 0000000..dc69d8e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchBarTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2023 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.widget;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.widget.TextView;
+
+import com.android.settingslib.R;
+import com.android.settingslib.RestrictedLockUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class SettingsMainSwitchBarTest {
+
+ private SettingsMainSwitchBar mMainSwitchBar;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ final Context context = RuntimeEnvironment.application;
+ mMainSwitchBar = new SettingsMainSwitchBar(context);
+ }
+
+ @Test
+ public void disabledByAdmin_shouldBeDisabled() {
+ mMainSwitchBar.setDisabledByAdmin(new RestrictedLockUtils.EnforcedAdmin());
+
+ TextView title = (TextView) mMainSwitchBar.findViewById(R.id.switch_text);
+ assertThat(title.isEnabled()).isFalse();
+ assertThat(mMainSwitchBar.getSwitch().isEnabled()).isFalse();
+ }
+
+ @Test
+ public void disabledByAdmin_setNull_shouldBeEnabled() {
+ mMainSwitchBar.setDisabledByAdmin(null);
+
+ TextView title = (TextView) mMainSwitchBar.findViewById(R.id.switch_text);
+ assertThat(title.isEnabled()).isTrue();
+ assertThat(mMainSwitchBar.getSwitch().isEnabled()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
index 0a54c88..fe663ab 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
@@ -16,10 +16,12 @@
package com.android.settings.wifi.tether;
+import static android.net.wifi.SoftApConfiguration.SECURITY_TYPE_WPA3_SAE;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static com.android.settings.wifi.WifiUtils.setCanShowWifiHotspotCached;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.BAND_2GHZ_5GHZ_6GHZ;
import static com.android.settings.wifi.tether.WifiTetherSettings.KEY_WIFI_HOTSPOT_SECURITY;
import static com.android.settings.wifi.tether.WifiTetherSettings.KEY_WIFI_HOTSPOT_SPEED;
@@ -41,6 +43,7 @@
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.TetheringManager;
+import android.net.wifi.SoftApConfiguration;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.UserManager;
@@ -84,6 +87,8 @@
private static final int XML_RES = R.xml.wifi_tether_settings;
private static final String[] WIFI_REGEXS = {"wifi_regexs"};
+ private static final String SSID = "ssid";
+ private static final String PASSWORD = "password";
@Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@@ -117,6 +122,12 @@
private LiveData<Integer> mSpeedSummary;
@Mock
private SettingsMainSwitchBar mMainSwitchBar;
+ @Mock
+ private WifiTetherSSIDPreferenceController mSSIDPreferenceController;
+ @Mock
+ private WifiTetherPasswordPreferenceController mPasswordPreferenceController;
+ @Mock
+ private WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController;
private WifiTetherSettings mSettings;
@@ -143,6 +154,12 @@
mSettings = spy(new WifiTetherSettings(mWifiRestriction));
mSettings.mMainSwitchBar = mMainSwitchBar;
+ mSettings.mSSIDPreferenceController = mSSIDPreferenceController;
+ when(mSSIDPreferenceController.getSSID()).thenReturn(SSID);
+ mSettings.mPasswordPreferenceController = mPasswordPreferenceController;
+ when(mPasswordPreferenceController.getPasswordValidated(anyInt())).thenReturn(PASSWORD);
+ mSettings.mWifiTetherAutoOffPreferenceController = mWifiTetherAutoOffPreferenceController;
+ when(mWifiTetherAutoOffPreferenceController.isEnabled()).thenReturn(true);
mSettings.mWifiTetherViewModel = mWifiTetherViewModel;
when(mSettings.findPreference(KEY_WIFI_HOTSPOT_SECURITY)).thenReturn(mWifiHotspotSecurity);
when(mSettings.findPreference(KEY_WIFI_HOTSPOT_SPEED)).thenReturn(mWifiHotspotSpeed);
@@ -327,6 +344,22 @@
}
@Test
+ public void buildNewConfig_speedFeatureIsAvailableAndPasswordChanged_bandShouldNotBeLost() {
+ String newPassword = "new" + PASSWORD;
+ SoftApConfiguration currentConfig = new SoftApConfiguration.Builder()
+ .setPassphrase(PASSWORD, SECURITY_TYPE_WPA3_SAE)
+ .setBand(BAND_2GHZ_5GHZ_6GHZ)
+ .build();
+ when(mWifiTetherViewModel.getSoftApConfiguration()).thenReturn(currentConfig);
+ when(mWifiTetherViewModel.isSpeedFeatureAvailable()).thenReturn(true);
+ when(mPasswordPreferenceController.getPasswordValidated(anyInt())).thenReturn(newPassword);
+
+ SoftApConfiguration newConfig = mSettings.buildNewConfig();
+
+ assertThat(newConfig.getBand()).isEqualTo(currentConfig.getBand());
+ }
+
+ @Test
public void onRestartingChanged_restartingFalse_setLoadingFalse() {
doNothing().when(mSettings).setLoading(anyBoolean(), anyBoolean());
diff --git a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
index 2a2aaee..3145cce 100644
--- a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
@@ -123,6 +123,25 @@
}
@Test
+ public void verifyHiddenIfAutofillSelectedProvider() {
+ CredentialManagerPreferenceController controller =
+ createControllerWithServices(Collections.emptyList());
+
+ // Set the autofill provider.
+ Settings.Secure.putStringForUser(mContext.getContentResolver(),
+ Settings.Secure.AUTOFILL_SERVICE, "com.example.test/AutofillClass",
+ UserHandle.myUserId());
+
+ // Verify the error cases
+ assertThat(controller.isProviderHiddenBecauseOfAutofill(null)).isFalse();
+ assertThat(controller.isProviderHiddenBecauseOfAutofill("")).isFalse();
+ assertThat(controller.isProviderHiddenBecauseOfAutofill("test")).isFalse();
+
+ // Verify the example.
+ assertThat(controller.isProviderHiddenBecauseOfAutofill("com.example.test")).isTrue();
+ }
+
+ @Test
public void displayPreference_noServices_noPreferencesAdded_useAutofillUri() {
Settings.Secure.putStringForUser(
mContext.getContentResolver(),