Block location accuracy when DISALLOW_CONFIG_LOCATION is set.

Bug: 72633181
Test: make ROBOTEST_FILTER=InjectedSettingTest -j40 RunSettingsRoboTests
Test: make ROBOTEST_FILTER=LocationServicePreferenceControllerTest -j40 RunSettingsRoboTests

Change-Id: I91e4dbff8bcce637424646f5435e72f9bb707631
This commit is contained in:
yuemingw
2018-02-01 13:57:52 +00:00
parent 106825383a
commit 3bf4b9365e
6 changed files with 347 additions and 42 deletions

View File

@@ -25,6 +25,7 @@ import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceScreen;
import android.util.Log;
import com.android.settings.widget.RestrictedAppPreference;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnPause;
@@ -88,7 +89,13 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC
@Override
public void updateState(Preference preference) {
mCategoryLocationServices.removeAll();
LocationSettings.addPreferencesSorted(getLocationServices(), mCategoryLocationServices);
final List<Preference> prefs = getLocationServices();
for (Preference pref : prefs) {
if (pref instanceof RestrictedAppPreference) {
((RestrictedAppPreference) pref).checkRestrictionAndSetDisabled();
}
}
LocationSettings.addPreferencesSorted(prefs, mCategoryLocationServices);
}
@Override