Merge "Maximize compatibility string update" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-04-07 09:24:44 +00:00
committed by Android (Google) Code Review
4 changed files with 40 additions and 11 deletions

View File

@@ -2508,9 +2508,11 @@
<!-- Summary for the toggle to turn off hotspot automatically [CHAR LIMIT=NONE]-->
<string name="wifi_hotspot_auto_off_summary">When no devices are connected</string>
<!-- Title for the toggle to enable/disable the maximize compatibility [CHAR LIMIT=NONE]-->
<string name="wifi_hotspot_maximize_compatibility">Maximize compatibility</string>
<!-- Summary for the toggle to show the maximize compatibility warning message [CHAR LIMIT=NONE]-->
<string name="wifi_hotspot_maximize_compatibility_summary">This may reduce speed for devices connected to this hotspot and use more power</string>
<string name="wifi_hotspot_maximize_compatibility">Extend compatibility</string>
<!-- Summary for the toggle to show the maximize compatibility warning message in single AP device [CHAR LIMIT=NONE]-->
<string name="wifi_hotspot_maximize_compatibility_single_ap_summary">Helps other devices find this hotspot. Reduces hotspot connection speed.</string>
<!-- Summary for the toggle to show the maximize compatibility warning message in dual AP device [CHAR LIMIT=NONE]-->
<string name="wifi_hotspot_maximize_compatibility_dual_ap_summary">Helps other devices find this hotspot. Increases battery usage.</string>
<!-- Summary text when turning hotspot on -->
<string name="wifi_tether_starting">Turning hotspot on\u2026</string>

View File

@@ -44,6 +44,5 @@
<SwitchPreference
android:key="wifi_tether_maximize_compatibility"
android:title="@string/wifi_hotspot_maximize_compatibility"
android:summary="@string/wifi_hotspot_maximize_compatibility_summary"/>
android:title="@string/wifi_hotspot_maximize_compatibility"/>
</PreferenceScreen>

View File

@@ -24,6 +24,8 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import com.android.settings.R;
/**
* This controller helps to manage the state of maximize compatibility switch preference.
*/
@@ -53,6 +55,9 @@ public class WifiTetherMaximizeCompatibilityPreferenceController extends
}
mPreference.setEnabled(is5GhzBandSupported());
((SwitchPreference) mPreference).setChecked(mIsChecked);
mPreference.setSummary(mWifiManager.isBridgedApConcurrencySupported()
? R.string.wifi_hotspot_maximize_compatibility_dual_ap_summary
: R.string.wifi_hotspot_maximize_compatibility_single_ap_summary);
}
@Override

View File

@@ -34,6 +34,8 @@ import androidx.preference.SwitchPreference;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settings.testutils.ResourcesUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -52,29 +54,30 @@ public class WifiTetherMaximizeCompatibilityPreferenceControllerTest {
@Mock
private WifiTetherBasePreferenceController.OnTetherConfigUpdateListener mListener;
private Context mContext;
private WifiTetherMaximizeCompatibilityPreferenceController mController;
private SwitchPreference mPreference;
private SoftApConfiguration mConfig;
@Before
public void setUp() {
final Context context = spy(ApplicationProvider.getApplicationContext());
mContext = spy(ApplicationProvider.getApplicationContext());
mConfig = new SoftApConfiguration.Builder()
.setSsid("test_Ssid")
.setPassphrase(null, SoftApConfiguration.SECURITY_TYPE_OPEN)
.setBridgedModeOpportunisticShutdownEnabled(true)
.build();
doReturn(mWifiManager).when(context).getSystemService(Context.WIFI_SERVICE);
doReturn(mWifiManager).when(mContext).getSystemService(Context.WIFI_SERVICE);
doReturn(true).when(mWifiManager).isBridgedApConcurrencySupported();
doReturn(mConfig).when(mWifiManager).getSoftApConfiguration();
mController = new WifiTetherMaximizeCompatibilityPreferenceController(context, mListener);
mController = new WifiTetherMaximizeCompatibilityPreferenceController(mContext, mListener);
if (Looper.myLooper() == null) {
Looper.prepare();
}
final PreferenceManager preferenceManager = new PreferenceManager(context);
final PreferenceScreen screen = preferenceManager.createPreferenceScreen(context);
mPreference = new SwitchPreference(context);
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
final PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
mPreference = new SwitchPreference(mContext);
mPreference.setKey(WifiTetherMaximizeCompatibilityPreferenceController.PREF_KEY);
screen.addPreference(mPreference);
mController.displayPreference(screen);
@@ -104,6 +107,26 @@ public class WifiTetherMaximizeCompatibilityPreferenceControllerTest {
assertThat(mPreference.isEnabled()).isEqualTo(false);
}
@Test
public void updateDisplay_notSupportedBridgedApConcurrency_setSingleApSummary() {
doReturn(false).when(mWifiManager).isBridgedApConcurrencySupported();
mController.updateDisplay();
assertThat(mPreference.getSummary()).isEqualTo(ResourcesUtils.getResourcesString(mContext,
"wifi_hotspot_maximize_compatibility_single_ap_summary"));
}
@Test
public void updateDisplay_supportedBridgedApConcurrency_setDualApSummary() {
doReturn(true).when(mWifiManager).isBridgedApConcurrencySupported();
mController.updateDisplay();
assertThat(mPreference.getSummary()).isEqualTo(ResourcesUtils.getResourcesString(mContext,
"wifi_hotspot_maximize_compatibility_dual_ap_summary"));
}
@Test
public void updateDisplay_supported5GHzBandAndCountryCodeIsNotNull_setPreferenceEnabled() {
doReturn(true).when(mWifiManager).is5GHzBandSupported();