Merge "Add a developer option to enable / disable location indicators."
This commit is contained in:
committed by
Android (Google) Code Review
commit
92107059b1
@@ -11403,6 +11403,19 @@
|
|||||||
<!-- Toast message shown when autofill_reset_developer_options has been performed. [CHAR_LIMIT=none] -->
|
<!-- Toast message shown when autofill_reset_developer_options has been performed. [CHAR_LIMIT=none] -->
|
||||||
<string name="autofill_reset_developer_options_complete">Autofill developer options have been reset</string>
|
<string name="autofill_reset_developer_options_complete">Autofill developer options have been reset</string>
|
||||||
|
|
||||||
|
<!-- Developer options location category strings -->
|
||||||
|
<!-- Title for privacy category [CHAR LIMIT=30]-->
|
||||||
|
<string name="location_category">Location</string>
|
||||||
|
<!-- [CHAR LIMIT=130] Title for location indicator settings -->
|
||||||
|
<string name="location_indicator_settings_title">Status bar location indicator</string>
|
||||||
|
<!-- [CHAR LIMIT=130] Description for location indicator settings -->
|
||||||
|
<string name="location_indicator_settings_description">Show for all locations, including network and connectivity</string>
|
||||||
|
|
||||||
|
<!-- Location setting: preference title - enforce full raw GNSS satellite measurements [CHAR LIMIT=60] -->
|
||||||
|
<string name="enable_gnss_raw_meas_full_tracking">Force full GNSS measurements</string>
|
||||||
|
<!-- Location setting: preference summary - describes the behavior of forcing full raw GNSS satellite measurements [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="enable_gnss_raw_meas_full_tracking_summary">Track all GNSS constellations and frequencies with no duty cycling</string>
|
||||||
|
|
||||||
<!-- Name of setting for switching device theme [CHAR LIMIT=60] -->
|
<!-- Name of setting for switching device theme [CHAR LIMIT=60] -->
|
||||||
<string name="device_theme">Device theme</string>
|
<string name="device_theme">Device theme</string>
|
||||||
<!-- Name of default device theme [CHAR LIMIT=60] -->
|
<!-- Name of default device theme [CHAR LIMIT=60] -->
|
||||||
@@ -11470,11 +11483,6 @@
|
|||||||
<!-- Part of a message for an empty state screen. A user will see this message if they try to use a certain feature, but the feature was turned off so it won't slow down their phone. [CHAR LIMIT=NONE] -->
|
<!-- Part of a message for an empty state screen. A user will see this message if they try to use a certain feature, but the feature was turned off so it won't slow down their phone. [CHAR LIMIT=NONE] -->
|
||||||
<string name="disabled_feature_reason_slow_down_phone">This feature has been turned off because it slows down your phone</string>
|
<string name="disabled_feature_reason_slow_down_phone">This feature has been turned off because it slows down your phone</string>
|
||||||
|
|
||||||
<!-- UI debug setting: preference title - enforce full raw GNSS satellite measurements [CHAR LIMIT=60] -->
|
|
||||||
<string name="enable_gnss_raw_meas_full_tracking">Force full GNSS measurements</string>
|
|
||||||
<!-- UI debug setting: preference summary - describes the behavior of forcing full raw GNSS satellite measurements [CHAR LIMIT=NONE] -->
|
|
||||||
<string name="enable_gnss_raw_meas_full_tracking_summary">Track all GNSS constellations and frequencies with no duty cycling</string>
|
|
||||||
|
|
||||||
<!-- UI debug setting: preference title - show all crash dialogs [CHAR LIMIT=60] -->
|
<!-- UI debug setting: preference title - show all crash dialogs [CHAR LIMIT=60] -->
|
||||||
<string name="show_first_crash_dialog">Always show crash dialog</string>
|
<string name="show_first_crash_dialog">Always show crash dialog</string>
|
||||||
<!-- UI debug setting: preference summary - describes the behavior of showing a dialog every time an app crashes [CHAR LIMIT=NONE] -->
|
<!-- UI debug setting: preference summary - describes the behavior of showing a dialog every time an app crashes [CHAR LIMIT=NONE] -->
|
||||||
|
@@ -175,14 +175,6 @@
|
|||||||
android:title="@string/automatic_system_heap_dump_title"
|
android:title="@string/automatic_system_heap_dump_title"
|
||||||
android:summary="@string/automatic_system_heap_dump_summary" />
|
android:summary="@string/automatic_system_heap_dump_summary" />
|
||||||
|
|
||||||
<Preference android:key="mock_location_app"
|
|
||||||
android:title="@string/mock_location_app" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="enable_gnss_raw_meas_full_tracking"
|
|
||||||
android:title="@string/enable_gnss_raw_meas_full_tracking"
|
|
||||||
android:summary="@string/enable_gnss_raw_meas_full_tracking_summary" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="debug_view_attributes"
|
android:key="debug_view_attributes"
|
||||||
android:title="@string/debug_view_attributes" />
|
android:title="@string/debug_view_attributes" />
|
||||||
@@ -696,4 +688,25 @@
|
|||||||
android:targetClass="com.android.settings.development.storage.BlobInfoListView" />
|
android:targetClass="com.android.settings.development.storage.BlobInfoListView" />
|
||||||
</Preference>
|
</Preference>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="location_category"
|
||||||
|
android:title="@string/location_category"
|
||||||
|
android:order="1300">
|
||||||
|
|
||||||
|
<Preference android:key="mock_location_app"
|
||||||
|
android:title="@string/mock_location_app" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="enable_gnss_raw_meas_full_tracking"
|
||||||
|
android:title="@string/enable_gnss_raw_meas_full_tracking"
|
||||||
|
android:summary="@string/enable_gnss_raw_meas_full_tracking_summary" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:title="@string/location_indicator_settings_title"
|
||||||
|
android:summary="@string/location_indicator_settings_description"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="location_indicator_settings"
|
||||||
|
settings:controller="com.android.settings.location.LocationIndicatorsPreferenceController"/>
|
||||||
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -142,6 +142,11 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
*/
|
*/
|
||||||
public static final String PROPERTY_PERMISSIONS_HUB_ENABLED = "permissions_hub_enabled";
|
public static final String PROPERTY_PERMISSIONS_HUB_ENABLED = "permissions_hub_enabled";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to show location indicators.
|
||||||
|
*/
|
||||||
|
public static final String PROPERTY_LOCATION_INDICATORS_ENABLED = "location_indicators_enabled";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a matching activity for a preference's intent. If a matching
|
* Finds a matching activity for a preference's intent. If a matching
|
||||||
* activity is not found, it will remove the preference.
|
* activity is not found, it will remove the preference.
|
||||||
|
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* 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.location;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
|
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
|
|
||||||
|
/** Controller for location indicators toggle. */
|
||||||
|
public class LocationIndicatorsPreferenceController extends TogglePreferenceController {
|
||||||
|
|
||||||
|
public LocationIndicatorsPreferenceController(Context context, String preferenceKey) {
|
||||||
|
super(context, preferenceKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isChecked() {
|
||||||
|
return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
|
Utils.PROPERTY_LOCATION_INDICATORS_ENABLED, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setChecked(boolean isChecked) {
|
||||||
|
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
|
Utils.PROPERTY_LOCATION_INDICATORS_ENABLED, Boolean.toString(isChecked), true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
// Location indicators feature is only available on devices that support location.
|
||||||
|
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION)
|
||||||
|
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* 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.location;
|
||||||
|
|
||||||
|
|
||||||
|
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
|
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit tests for {@link LocationIndicatorsPreferenceController}.
|
||||||
|
*/
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Config(shadows = {ShadowDeviceConfig.class})
|
||||||
|
public class LocationIndicatorsPreferenceControllerTest {
|
||||||
|
@Mock
|
||||||
|
PackageManager mPackageManager;
|
||||||
|
private Context mContext;
|
||||||
|
private LocationIndicatorsPreferenceController mController;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
mController = new LocationIndicatorsPreferenceController(mContext, "key");
|
||||||
|
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowDeviceConfig.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the location indicator settings are visible when location feature is supported
|
||||||
|
* on the device.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_locationSupported_shouldReturnAVAILABLE() {
|
||||||
|
when(mPackageManager.hasSystemFeature(eq(PackageManager.FEATURE_LOCATION))).thenReturn(
|
||||||
|
true);
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the location indicator settings are not visible when location feature is not supported
|
||||||
|
* on the device.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_locationNotSupported_shouldReturnUNSUPPORTED() {
|
||||||
|
when(mPackageManager.hasSystemFeature(eq(PackageManager.FEATURE_LOCATION))).thenReturn(
|
||||||
|
false);
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the location indicator preference is checked when the feature is enabled.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void isChecked_featureEnabled_shouldReturnTrue() {
|
||||||
|
final boolean enabled = true;
|
||||||
|
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
|
Utils.PROPERTY_LOCATION_INDICATORS_ENABLED, Boolean.toString(enabled), true);
|
||||||
|
assertThat(mController.isChecked()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the location indicator preference is unchecked when the feature is not enabled.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void isChecked_featureNotEnabled_shouldReturnFalse() {
|
||||||
|
final boolean enabled = false;
|
||||||
|
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_PRIVACY,
|
||||||
|
Utils.PROPERTY_LOCATION_INDICATORS_ENABLED, Boolean.toString(enabled), true);
|
||||||
|
assertThat(mController.isChecked()).isFalse();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user