Merge "Allows for system navigation settings to be added dynamically." into main

This commit is contained in:
Andy Wickham
2024-03-20 03:00:10 +00:00
committed by Android (Google) Code Review
6 changed files with 133 additions and 5 deletions

View File

@@ -20,6 +20,8 @@ import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import androidx.preference.PreferenceManager;
import com.android.settings.R;
import com.android.settings.slices.FakePreferenceController;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -38,10 +40,12 @@ import java.util.List;
public class PreferenceControllerListHelperTest {
private Context mContext;
private PreferenceManager mPreferenceManager;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mPreferenceManager = new PreferenceManager(mContext);
}
@Test
@@ -68,6 +72,30 @@ public class PreferenceControllerListHelperTest {
assertThat(controllers.get(0)).isInstanceOf(FakePreferenceController.class);
}
@Test
@Config(qualifiers = "mcc999")
public void areAllPreferencesUnavailable_allAvailable() {
// All preferences have controllers indicating they are available.
assertThat(PreferenceControllerListHelper.areAllPreferencesUnavailable(mContext,
mPreferenceManager, R.xml.location_settings)).isFalse();
}
@Test
@Config(qualifiers = "mcc997")
public void areAllPreferencesUnavailable_allUnavailable() {
// All preferences have controllers indicating they are unavailable. (note the qualifier)
assertThat(PreferenceControllerListHelper.areAllPreferencesUnavailable(mContext,
mPreferenceManager, R.xml.location_settings)).isTrue();
}
@Test
@Config(qualifiers = "mcc999")
public void areAllPreferencesUnavailable_noControllersShouldAssumeAvailable() {
// None of the preferences have controllers, so they are assumed available.
assertThat(PreferenceControllerListHelper.areAllPreferencesUnavailable(mContext,
mPreferenceManager, R.xml.display_settings)).isFalse();
}
@Test
public void filterControllers_noFilter_shouldReturnSameList() {
final List<BasePreferenceController> controllers = new ArrayList<>();

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2024 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.core;
import android.content.Context;
public class UnavailablePreferenceController extends BasePreferenceController {
public UnavailablePreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@Override
public int getAvailabilityStatus() {
return UNSUPPORTED_ON_DEVICE;
}
}