This change adds a new entry for geolocation-based time zone detection (shorthand: "geotz") to the location settings. The UI code uses information retrieved via the TimeManager API to keep the conditional logic in one place, i.e. to avoid the UI needing to know too much about the various conditions that affect the availability / applicability of the toggle. Screen variations / conditions / other info: Location settings screen: 1) The entry only shows up on a device at all if geotz detection is enabled for the device (currently a compile time setting, off by default). 2) The new entry is hidden on the screen when the user first opens it. To see it, the user has to expand "Advanced". The setting is in the shared (non-GMS) section of the screen. 3) When visible, the entry has a summary that shows the current status: either a reason why the setting is not applicable, or the user's current setting value. 4) Selecting the entry opens a sub-screen. The code included here distinguishes between different cases with the summary message (i.e. the text underneath the entry). See strings.xml for the placeholder text. Some strings will not show up currently, but are included in case the rules change as they are valid possibilities from the TimeManager API. The same changes have been made for the "personal" tab when a work profile is enabled. Location Time Zone Detection settings screen: 1) The toggle is always enabled and always shows the user's current configuration setting. All manual tests run with the geotz feature enabled with: adb shell setprop \ persist.sys.location_time_zone_detection_feature_enabled 1 Bug: 152746236 Test: Manual: build / boot / toggle switch in SettingsUI / inspect output of adb shell dumpsys time_zone_detector Test: Manual: build / boot / install TestDPC / toggle switch in work profile in SettingsUI / inspect output of adb shell dumpsys time_zone_detector Test: m -j30 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.location.TimeZoneDetectionPreferenceControllerTest" Test: m -j30 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.location.LocationTimeZoneDetectionPreferenceControllerTest" Test: m -j30 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.location.TimeZoneDetectionSettingsTest" Change-Id: Ia853d30bc54a113000b30f48776418f262d98358
76 lines
2.5 KiB
Java
76 lines
2.5 KiB
Java
/*
|
|
* 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.app.settings.SettingsEnums;
|
|
import android.content.Context;
|
|
|
|
import com.android.settings.R;
|
|
import com.android.settings.dashboard.DashboardFragment;
|
|
import com.android.settings.search.BaseSearchIndexProvider;
|
|
import com.android.settingslib.core.AbstractPreferenceController;
|
|
import com.android.settingslib.search.SearchIndexable;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* The controller for the "location time zone detection" screen.
|
|
*/
|
|
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
|
public class TimeZoneDetectionSettings extends DashboardFragment {
|
|
private static final String TAG = "LTZDetectionSettings";
|
|
|
|
@Override
|
|
public int getMetricsCategory() {
|
|
return SettingsEnums.LOCATION_TIME_ZONE_DETECTION;
|
|
}
|
|
|
|
@Override
|
|
protected int getPreferenceScreenResId() {
|
|
return R.xml.location_time_zone_detection;
|
|
}
|
|
|
|
@Override
|
|
protected String getLogTag() {
|
|
return TAG;
|
|
}
|
|
|
|
@Override
|
|
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
|
return buildPreferenceControllers(context);
|
|
}
|
|
|
|
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
|
|
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
|
controllers.add(new TimeZoneDetectionPreferenceController(context));
|
|
return controllers;
|
|
}
|
|
|
|
/**
|
|
* For Search.
|
|
*/
|
|
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
|
new BaseSearchIndexProvider(R.xml.location_time_zone_detection) {
|
|
|
|
@Override
|
|
public List<AbstractPreferenceController> createPreferenceControllers(Context
|
|
context) {
|
|
return buildPreferenceControllers(context);
|
|
}
|
|
};
|
|
}
|