Loading res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -456,4 +456,7 @@ <!-- Whether nfc detection point preview image is available or not. --> <bool name="config_nfc_detection_point">false</bool> <!-- Whether to show Enhanced Connectivity switch in Developer Options --> <bool name="config_show_enhanced_connectivity">false</bool> </resources> src/com/android/settings/development/EnhancedConnectivityPreferenceController.java +6 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import androidx.preference.Preference; import androidx.preference.SwitchPreference; import com.android.internal.annotations.VisibleForTesting; import com.android.settings.R; import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.development.DeveloperOptionsPreferenceController; Loading Loading @@ -70,6 +71,11 @@ public class EnhancedConnectivityPreferenceController extends enhancedConnectivityEnabled == ENHANCED_CONNECTIVITY_ON); } @Override public boolean isAvailable() { return mContext.getResources().getBoolean(R.bool.config_show_enhanced_connectivity); } @Override protected void onDeveloperOptionsSwitchDisabled() { super.onDeveloperOptionsSwitchDisabled(); Loading tests/robotests/src/com/android/settings/development/EnhancedConnectivityPreferenceControllerTest.java +27 −1 Original line number Diff line number Diff line Loading @@ -27,16 +27,19 @@ import android.provider.Settings; import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreference; import com.android.settings.R; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Answers; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; @RunWith(RobolectricTestRunner.class) public class EnhancedConnectivityPreferenceControllerTest { @Mock @Mock(answer = Answers.RETURNS_DEEP_STUBS) private Context mContext; @Mock Loading Loading @@ -97,6 +100,29 @@ public class EnhancedConnectivityPreferenceControllerTest { assertThat(isSettingEnabled()).isTrue(); } @Test public void isAvailable_enhancedConnectivityShown_shouldReturnTrue() { enableEnhancedConnectivityPreference(true); boolean availability = mController.isAvailable(); assertThat(availability).isTrue(); } @Test public void isAvailable_enhancedConnectivityNotShown_shouldReturnFalse() { enableEnhancedConnectivityPreference(false); boolean availability = mController.isAvailable(); assertThat(availability).isFalse(); } private void enableEnhancedConnectivityPreference(boolean enable) { when(mContext.getResources().getBoolean(R.bool.config_show_enhanced_connectivity)) .thenReturn(enable); } private boolean isSettingEnabled() { return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.ENHANCED_CONNECTIVITY_ENABLED, Loading Loading
res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -456,4 +456,7 @@ <!-- Whether nfc detection point preview image is available or not. --> <bool name="config_nfc_detection_point">false</bool> <!-- Whether to show Enhanced Connectivity switch in Developer Options --> <bool name="config_show_enhanced_connectivity">false</bool> </resources>
src/com/android/settings/development/EnhancedConnectivityPreferenceController.java +6 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import androidx.preference.Preference; import androidx.preference.SwitchPreference; import com.android.internal.annotations.VisibleForTesting; import com.android.settings.R; import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.development.DeveloperOptionsPreferenceController; Loading Loading @@ -70,6 +71,11 @@ public class EnhancedConnectivityPreferenceController extends enhancedConnectivityEnabled == ENHANCED_CONNECTIVITY_ON); } @Override public boolean isAvailable() { return mContext.getResources().getBoolean(R.bool.config_show_enhanced_connectivity); } @Override protected void onDeveloperOptionsSwitchDisabled() { super.onDeveloperOptionsSwitchDisabled(); Loading
tests/robotests/src/com/android/settings/development/EnhancedConnectivityPreferenceControllerTest.java +27 −1 Original line number Diff line number Diff line Loading @@ -27,16 +27,19 @@ import android.provider.Settings; import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreference; import com.android.settings.R; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Answers; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; @RunWith(RobolectricTestRunner.class) public class EnhancedConnectivityPreferenceControllerTest { @Mock @Mock(answer = Answers.RETURNS_DEEP_STUBS) private Context mContext; @Mock Loading Loading @@ -97,6 +100,29 @@ public class EnhancedConnectivityPreferenceControllerTest { assertThat(isSettingEnabled()).isTrue(); } @Test public void isAvailable_enhancedConnectivityShown_shouldReturnTrue() { enableEnhancedConnectivityPreference(true); boolean availability = mController.isAvailable(); assertThat(availability).isTrue(); } @Test public void isAvailable_enhancedConnectivityNotShown_shouldReturnFalse() { enableEnhancedConnectivityPreference(false); boolean availability = mController.isAvailable(); assertThat(availability).isFalse(); } private void enableEnhancedConnectivityPreference(boolean enable) { when(mContext.getResources().getBoolean(R.bool.config_show_enhanced_connectivity)) .thenReturn(enable); } private boolean isSettingEnabled() { return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.ENHANCED_CONNECTIVITY_ENABLED, Loading