import com.android.settings.display.TimeoutPreferenceController;
import com.android.settings.display.VrDisplayPreferenceController;
import com.android.settings.display.WallpaperPreferenceController;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
@Override
protected int getPreferenceScreenResId() {
- return R.xml.ia_display_settings;
+ return R.xml.display_settings;
}
@Override
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.ia_display_settings;
+ sir.xmlResId = R.xml.display_settings;
result.add(sir);
return result;
}
@Override
protected int getPreferenceScreenResId() {
- return R.xml.ia_sound_settings;
+ return R.xml.sound_settings;
}
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(
Context context, boolean enabled) {
final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.ia_sound_settings;
+ sir.xmlResId = R.xml.sound_settings;
return Arrays.asList(sir);
}
KEY_WORK_ALARM_RINGTONE);
}
if (!mVoiceCapable) {
- mWorkPreferenceCategory.removePreference(mWorkPhoneRingtonePreference);
+ mWorkPhoneRingtonePreference.setVisible(false);
mWorkPhoneRingtonePreference = null;
}
mController.displayPreference(mScreen);
verify(mWorkCategory).setVisible(false);
-
// However, when a managed profile is added later, the category should appear.
mController.onResume();
when(mAudioHelper.getManagedProfileId(any(UserManager.class)))
}
@Test
+ public void onResume_noVoiceCapability_shouldHidePhoneRingtone() {
+ when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
+ mController = new WorkSoundPreferenceController(mContext, mFragment, null, mAudioHelper);
+
+ when(mAudioHelper.getManagedProfileId(any(UserManager.class)))
+ .thenReturn(UserHandle.myUserId());
+ when(mAudioHelper.isUserUnlocked(any(UserManager.class), anyInt())).thenReturn(true);
+ when(mAudioHelper.isSingleVolume()).thenReturn(false);
+ when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
+ when(mAudioHelper.createPackageContextAsUser(anyInt())).thenReturn(mContext);
+
+ // Precondition: work profile is available.
+ assertThat(mController.isAvailable()).isTrue();
+
+ mController.displayPreference(mScreen);
+ mController.onResume();
+
+ verify(mWorkCategory.findPreference(KEY_WORK_PHONE_RINGTONE)).setVisible(false);
+ }
+
+ @Test
public void onResume_availableButLocked_shouldRedactPreferences() {
final String notAvailable = "(not available)";
when(mContext.getString(R.string.managed_profile_not_available_label))
@Test
public void testDataTitleValid_ReturnsPreferenceTitle() {
- XmlResourceParser parser = getChildByType(R.xml.ia_display_settings,
+ XmlResourceParser parser = getChildByType(R.xml.display_settings,
"com.android.settings.TimeoutListPreference");
final AttributeSet attrs = Xml.asAttributeSet(parser);
String title = XmlParserUtils.getDataTitle(mContext, attrs);
@Test
public void testDataKeywordsValid_ReturnsPreferenceKeywords() {
- XmlResourceParser parser = getParentPrimedParser(R.xml.ia_display_settings);
+ XmlResourceParser parser = getParentPrimedParser(R.xml.display_settings);
final AttributeSet attrs = Xml.asAttributeSet(parser);
String keywords = XmlParserUtils.getDataKeywords(mContext, attrs);
String expKeywords = mContext.getString(R.string.keywords_display);
@Test
public void testDataKeyValid_ReturnsPreferenceKey() {
- XmlResourceParser parser = getChildByType(R.xml.ia_display_settings,
+ XmlResourceParser parser = getChildByType(R.xml.display_settings,
"com.android.settings.TimeoutListPreference");
final AttributeSet attrs = Xml.asAttributeSet(parser);
String key = XmlParserUtils.getDataKey(mContext, attrs);
@Test
public void testDataSummaryValid_ReturnsPreferenceSummary() {
- XmlResourceParser parser = getChildByType(R.xml.ia_display_settings,
+ XmlResourceParser parser = getChildByType(R.xml.display_settings,
"com.android.settings.TimeoutListPreference");
final AttributeSet attrs = Xml.asAttributeSet(parser);
String summary = XmlParserUtils.getDataSummary(mContext, attrs);
@Test
public void testDataKeyInvalid_ReturnsNull() {
- XmlResourceParser parser = getParentPrimedParser(R.xml.ia_display_settings);
+ XmlResourceParser parser = getParentPrimedParser(R.xml.display_settings);
final AttributeSet attrs = Xml.asAttributeSet(parser);
String key = XmlParserUtils.getDataKey(mContext, attrs);
assertThat(key).isNull();
@Test
public void testDataSummaryInvalid_ReturnsNull() {
- XmlResourceParser parser = getParentPrimedParser(R.xml.ia_display_settings);
+ XmlResourceParser parser = getParentPrimedParser(R.xml.display_settings);
final AttributeSet attrs = Xml.asAttributeSet(parser);
String summary = XmlParserUtils.getDataSummary(mContext, attrs);
assertThat(summary).isNull();
@Test
public void testDataSummaryOffInvalid_ReturnsNull() {
- XmlResourceParser parser = getParentPrimedParser(R.xml.ia_display_settings);
+ XmlResourceParser parser = getParentPrimedParser(R.xml.display_settings);
final AttributeSet attrs = Xml.asAttributeSet(parser);
String summaryOff = XmlParserUtils.getDataSummaryOff(mContext, attrs);
assertThat(summaryOff).isNull();
@Test
public void testDataEntriesInvalid_ReturnsNull() {
- XmlResourceParser parser = getParentPrimedParser(R.xml.ia_display_settings);
+ XmlResourceParser parser = getParentPrimedParser(R.xml.display_settings);
final AttributeSet attrs = Xml.asAttributeSet(parser);
String entries = XmlParserUtils.getDataEntries(mContext, attrs);
assertThat(entries).isNull();
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowApplication;
import org.robolectric.shadows.ShadowContentResolver;
import java.util.ArrayList;
@Test
public void testAddResource_RowsInserted() {
- SearchIndexableResource resource = getFakeResource(R.xml.ia_display_settings);
+ SearchIndexableResource resource = getFakeResource(R.xml.display_settings);
mManager.indexOneSearchIndexableData(mDb, localeStr, resource, new HashMap<>());
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index", null);
assertThat(cursor.getCount()).isEqualTo(16);
@Test
public void testAddResource_withNIKs_rowsInsertedDisabled() {
- SearchIndexableResource resource = getFakeResource(R.xml.ia_display_settings);
+ SearchIndexableResource resource = getFakeResource(R.xml.display_settings);
// Only add 2 of 16 items to be disabled.
String[] keys = {"brightness", "wallpaper"};
Map<String, Set<String>> niks = getNonIndexableKeys(keys);