ARC++ PH: Location UI Changes

UI changes for privacy hub to disable location settings if setting is
managed by Chrome and feature is turned on.

Bug: 265471993
Test: Manual

Change-Id: I55ba35493d27a8a545765c5602a76dc124c24d98
(cherry picked from commit 1795f20cc54528a11fd0f2f72a9f782c64245eb0)
This commit is contained in:
Varun Somani
2022-12-22 22:06:28 +00:00
parent a579912892
commit e69e72b1e4
3 changed files with 28 additions and 0 deletions

View File

@@ -787,4 +787,7 @@
<!-- Whether location services setting is available or not. -->
<bool name="config_show_location_services">true</bool>
<!-- Whether to disable location toggle for ChromeOS devices-->
<bool name="config_disable_location_toggle_for_chrome">false</bool>
</resources>

View File

@@ -663,6 +663,8 @@
<string name="location_settings_footer_learn_more_content_description">
Learn more about Location settings
</string>
<!-- Tooltip for switchbar on Chrome devices. [CHAR LIMIT=90]-->
<string name="location_settings_tooltip_text_for_chrome">To change location access, go to Settings > Security and Privacy > Privacy controls</string>
<!-- Main Settings screen setting option title for the item to take you to the accounts screen [CHAR LIMIT=22] -->
<string name="account_settings_title">Accounts</string>

View File

@@ -25,7 +25,9 @@ import android.location.SettingInjectorService;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemProperties;
import android.provider.Settings;
import android.util.Log;
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
@@ -72,6 +74,13 @@ public class LocationSettings extends DashboardFragment implements
private RecentLocationAccessPreferenceController mController;
private ContentObserver mContentObserver;
/**
* Read-only boot property used to enable/disable geolocation toggle as part of privacy hub
* feature for chrome.
*/
private static final String RO_BOOT_ENABLE_PRIVACY_HUB_FOR_CHROME =
"ro.boot.enable_privacy_hub_for_chrome";
@Override
public int getMetricsCategory() {
return SettingsEnums.LOCATION;
@@ -83,6 +92,7 @@ public class LocationSettings extends DashboardFragment implements
final SettingsActivity activity = (SettingsActivity) getActivity();
final SettingsMainSwitchBar switchBar = activity.getSwitchBar();
switchBar.setTitle(getContext().getString(R.string.location_settings_primary_switch_title));
updateChromeSwitchBarPreference(switchBar);
switchBar.show();
mSwitchBarController = new LocationSwitchBarController(activity, switchBar,
getSettingsLifecycle());
@@ -161,4 +171,17 @@ public class LocationSettings extends DashboardFragment implements
*/
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.location_settings);
/**
* Update switchbar config in case of Chrome devices and location is managed by chrome.
*/
private void updateChromeSwitchBarPreference(final SettingsMainSwitchBar switchBar) {
if (getContext().getResources().getBoolean(R.bool.config_disable_location_toggle_for_chrome)
&& SystemProperties.getBoolean(RO_BOOT_ENABLE_PRIVACY_HUB_FOR_CHROME, false)) {
Log.i(TAG, "Disabling location toggle for chrome devices");
switchBar.setClickable(false);
switchBar.setTooltipText(getResources().getString(
R.string.location_settings_tooltip_text_for_chrome));
}
}
}