Fix a crash when resuming sound setting with AfW on Ryu
Also renamed a few xmls Change-Id: I8ff5a778a39ea45471a27048be4ea2f21075872a Fix: 36357493 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -36,7 +36,6 @@ import com.android.settings.display.ThemePreferenceController;
|
||||
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;
|
||||
|
||||
@@ -64,7 +63,7 @@ public class DisplaySettings extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.ia_display_settings;
|
||||
return R.xml.display_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,7 +103,7 @@ public class DisplaySettings extends DashboardFragment {
|
||||
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;
|
||||
}
|
||||
|
@@ -98,7 +98,7 @@ public class SoundSettings extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.ia_sound_settings;
|
||||
return R.xml.sound_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,7 +216,7 @@ public class SoundSettings extends DashboardFragment {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@@ -222,7 +222,7 @@ public class WorkSoundPreferenceController extends PreferenceController implemen
|
||||
KEY_WORK_ALARM_RINGTONE);
|
||||
}
|
||||
if (!mVoiceCapable) {
|
||||
mWorkPreferenceCategory.removePreference(mWorkPhoneRingtonePreference);
|
||||
mWorkPhoneRingtonePreference.setVisible(false);
|
||||
mWorkPhoneRingtonePreference = null;
|
||||
}
|
||||
|
||||
|
@@ -134,7 +134,6 @@ public class WorkSoundPreferenceControllerTest {
|
||||
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)))
|
||||
@@ -203,6 +202,27 @@ public class WorkSoundPreferenceControllerTest {
|
||||
verify(preference).setSummary(anyString());
|
||||
}
|
||||
|
||||
@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)";
|
||||
|
@@ -56,7 +56,7 @@ public class XmlParserUtilTest {
|
||||
|
||||
@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);
|
||||
@@ -66,7 +66,7 @@ public class XmlParserUtilTest {
|
||||
|
||||
@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);
|
||||
@@ -75,7 +75,7 @@ public class XmlParserUtilTest {
|
||||
|
||||
@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);
|
||||
@@ -85,7 +85,7 @@ public class XmlParserUtilTest {
|
||||
|
||||
@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);
|
||||
@@ -128,7 +128,7 @@ public class XmlParserUtilTest {
|
||||
|
||||
@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();
|
||||
@@ -136,7 +136,7 @@ public class XmlParserUtilTest {
|
||||
|
||||
@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();
|
||||
@@ -144,7 +144,7 @@ public class XmlParserUtilTest {
|
||||
|
||||
@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();
|
||||
@@ -152,7 +152,7 @@ public class XmlParserUtilTest {
|
||||
|
||||
@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();
|
||||
|
@@ -49,7 +49,6 @@ import org.mockito.Mock;
|
||||
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;
|
||||
@@ -248,7 +247,7 @@ public class DatabaseIndexingManagerTest {
|
||||
|
||||
@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);
|
||||
@@ -256,7 +255,7 @@ public class DatabaseIndexingManagerTest {
|
||||
|
||||
@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);
|
||||
|
Reference in New Issue
Block a user