Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 607cd20a authored by Ben Lin's avatar Ben Lin
Browse files

Add XML attribute to toggle on/off LocationModePreferenceController.

Test: make RunSettingsRoboTests
ROBOTEST_FILTER=LocationModePreferenceControllerTest all pass.
Bug: 62378711

Change-Id: I0d054171b80b5677dba2a7a02fb076660ed5cc0d
parent cad68b3c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -48,4 +48,7 @@

    <!--Whether help links are defined. -->
    <bool name="config_has_help">false</bool>

    <!-- Whether location mode is available or not. -->
    <bool name="config_location_mode_available">true</bool>
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -40,6 +40,11 @@ public class LocationModePreferenceController extends LocationBasePreferenceCont
        return KEY_LOCATION_MODE;
    }

    @Override
    public boolean isAvailable() {
        return mContext.getResources().getBoolean(R.bool.config_location_mode_available);
    }

    @Override
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);
+1 −0
Original line number Diff line number Diff line
@@ -20,4 +20,5 @@
    <bool name="config_show_camera_laser_sensor">false</bool>
    <bool name="config_show_connectivity_monitor">false</bool>
    <bool name="config_display_recent_apps">false</bool>
    <bool name="config_location_mode_available">false</bool>
</resources>
 No newline at end of file
+13 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.settings.location;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -72,6 +74,17 @@ public class LocationModePreferenceControllerTest {
        when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    }

    @Test
    @Config(qualifiers = "mcc999")
    public void locationModePreference_ifXmlSetToFalse_shouldNotBeAvailable() {
        assertFalse(mController.isAvailable());
    }

    @Test
    public void locationModePreference_ifXmlSetToTrue_shouldBeAvailable() {
        assertTrue(mController.isAvailable());
    }

    @Test
    public void onLocationModeChanged_locationOff_shouldDisablePreference() {
        when(mUserManager.hasUserRestriction(any())).thenReturn(false);