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.TimeoutPreferenceController;
|
||||||
import com.android.settings.display.VrDisplayPreferenceController;
|
import com.android.settings.display.VrDisplayPreferenceController;
|
||||||
import com.android.settings.display.WallpaperPreferenceController;
|
import com.android.settings.display.WallpaperPreferenceController;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.search.Indexable;
|
import com.android.settings.search.Indexable;
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ public class DisplaySettings extends DashboardFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPreferenceScreenResId() {
|
protected int getPreferenceScreenResId() {
|
||||||
return R.xml.ia_display_settings;
|
return R.xml.display_settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -104,7 +103,7 @@ public class DisplaySettings extends DashboardFragment {
|
|||||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||||
|
|
||||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||||
sir.xmlResId = R.xml.ia_display_settings;
|
sir.xmlResId = R.xml.display_settings;
|
||||||
result.add(sir);
|
result.add(sir);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -98,7 +98,7 @@ public class SoundSettings extends DashboardFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPreferenceScreenResId() {
|
protected int getPreferenceScreenResId() {
|
||||||
return R.xml.ia_sound_settings;
|
return R.xml.sound_settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -216,7 +216,7 @@ public class SoundSettings extends DashboardFragment {
|
|||||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||||
Context context, boolean enabled) {
|
Context context, boolean enabled) {
|
||||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||||
sir.xmlResId = R.xml.ia_sound_settings;
|
sir.xmlResId = R.xml.sound_settings;
|
||||||
return Arrays.asList(sir);
|
return Arrays.asList(sir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -222,7 +222,7 @@ public class WorkSoundPreferenceController extends PreferenceController implemen
|
|||||||
KEY_WORK_ALARM_RINGTONE);
|
KEY_WORK_ALARM_RINGTONE);
|
||||||
}
|
}
|
||||||
if (!mVoiceCapable) {
|
if (!mVoiceCapable) {
|
||||||
mWorkPreferenceCategory.removePreference(mWorkPhoneRingtonePreference);
|
mWorkPhoneRingtonePreference.setVisible(false);
|
||||||
mWorkPhoneRingtonePreference = null;
|
mWorkPhoneRingtonePreference = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -134,7 +134,6 @@ public class WorkSoundPreferenceControllerTest {
|
|||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
verify(mWorkCategory).setVisible(false);
|
verify(mWorkCategory).setVisible(false);
|
||||||
|
|
||||||
|
|
||||||
// However, when a managed profile is added later, the category should appear.
|
// However, when a managed profile is added later, the category should appear.
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
when(mAudioHelper.getManagedProfileId(any(UserManager.class)))
|
when(mAudioHelper.getManagedProfileId(any(UserManager.class)))
|
||||||
@@ -203,6 +202,27 @@ public class WorkSoundPreferenceControllerTest {
|
|||||||
verify(preference).setSummary(anyString());
|
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
|
@Test
|
||||||
public void onResume_availableButLocked_shouldRedactPreferences() {
|
public void onResume_availableButLocked_shouldRedactPreferences() {
|
||||||
final String notAvailable = "(not available)";
|
final String notAvailable = "(not available)";
|
||||||
|
@@ -56,7 +56,7 @@ public class XmlParserUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDataTitleValid_ReturnsPreferenceTitle() {
|
public void testDataTitleValid_ReturnsPreferenceTitle() {
|
||||||
XmlResourceParser parser = getChildByType(R.xml.ia_display_settings,
|
XmlResourceParser parser = getChildByType(R.xml.display_settings,
|
||||||
"com.android.settings.TimeoutListPreference");
|
"com.android.settings.TimeoutListPreference");
|
||||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||||
String title = XmlParserUtils.getDataTitle(mContext, attrs);
|
String title = XmlParserUtils.getDataTitle(mContext, attrs);
|
||||||
@@ -66,7 +66,7 @@ public class XmlParserUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDataKeywordsValid_ReturnsPreferenceKeywords() {
|
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);
|
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||||
String keywords = XmlParserUtils.getDataKeywords(mContext, attrs);
|
String keywords = XmlParserUtils.getDataKeywords(mContext, attrs);
|
||||||
String expKeywords = mContext.getString(R.string.keywords_display);
|
String expKeywords = mContext.getString(R.string.keywords_display);
|
||||||
@@ -75,7 +75,7 @@ public class XmlParserUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDataKeyValid_ReturnsPreferenceKey() {
|
public void testDataKeyValid_ReturnsPreferenceKey() {
|
||||||
XmlResourceParser parser = getChildByType(R.xml.ia_display_settings,
|
XmlResourceParser parser = getChildByType(R.xml.display_settings,
|
||||||
"com.android.settings.TimeoutListPreference");
|
"com.android.settings.TimeoutListPreference");
|
||||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||||
String key = XmlParserUtils.getDataKey(mContext, attrs);
|
String key = XmlParserUtils.getDataKey(mContext, attrs);
|
||||||
@@ -85,7 +85,7 @@ public class XmlParserUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDataSummaryValid_ReturnsPreferenceSummary() {
|
public void testDataSummaryValid_ReturnsPreferenceSummary() {
|
||||||
XmlResourceParser parser = getChildByType(R.xml.ia_display_settings,
|
XmlResourceParser parser = getChildByType(R.xml.display_settings,
|
||||||
"com.android.settings.TimeoutListPreference");
|
"com.android.settings.TimeoutListPreference");
|
||||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||||
String summary = XmlParserUtils.getDataSummary(mContext, attrs);
|
String summary = XmlParserUtils.getDataSummary(mContext, attrs);
|
||||||
@@ -128,7 +128,7 @@ public class XmlParserUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDataKeyInvalid_ReturnsNull() {
|
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);
|
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||||
String key = XmlParserUtils.getDataKey(mContext, attrs);
|
String key = XmlParserUtils.getDataKey(mContext, attrs);
|
||||||
assertThat(key).isNull();
|
assertThat(key).isNull();
|
||||||
@@ -136,7 +136,7 @@ public class XmlParserUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDataSummaryInvalid_ReturnsNull() {
|
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);
|
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||||
String summary = XmlParserUtils.getDataSummary(mContext, attrs);
|
String summary = XmlParserUtils.getDataSummary(mContext, attrs);
|
||||||
assertThat(summary).isNull();
|
assertThat(summary).isNull();
|
||||||
@@ -144,7 +144,7 @@ public class XmlParserUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDataSummaryOffInvalid_ReturnsNull() {
|
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);
|
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||||
String summaryOff = XmlParserUtils.getDataSummaryOff(mContext, attrs);
|
String summaryOff = XmlParserUtils.getDataSummaryOff(mContext, attrs);
|
||||||
assertThat(summaryOff).isNull();
|
assertThat(summaryOff).isNull();
|
||||||
@@ -152,7 +152,7 @@ public class XmlParserUtilTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDataEntriesInvalid_ReturnsNull() {
|
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);
|
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||||
String entries = XmlParserUtils.getDataEntries(mContext, attrs);
|
String entries = XmlParserUtils.getDataEntries(mContext, attrs);
|
||||||
assertThat(entries).isNull();
|
assertThat(entries).isNull();
|
||||||
|
@@ -49,7 +49,6 @@ import org.mockito.Mock;
|
|||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowApplication;
|
|
||||||
import org.robolectric.shadows.ShadowContentResolver;
|
import org.robolectric.shadows.ShadowContentResolver;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -248,7 +247,7 @@ public class DatabaseIndexingManagerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddResource_RowsInserted() {
|
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<>());
|
mManager.indexOneSearchIndexableData(mDb, localeStr, resource, new HashMap<>());
|
||||||
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index", null);
|
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index", null);
|
||||||
assertThat(cursor.getCount()).isEqualTo(16);
|
assertThat(cursor.getCount()).isEqualTo(16);
|
||||||
@@ -256,7 +255,7 @@ public class DatabaseIndexingManagerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddResource_withNIKs_rowsInsertedDisabled() {
|
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.
|
// Only add 2 of 16 items to be disabled.
|
||||||
String[] keys = {"brightness", "wallpaper"};
|
String[] keys = {"brightness", "wallpaper"};
|
||||||
Map<String, Set<String>> niks = getNonIndexableKeys(keys);
|
Map<String, Set<String>> niks = getNonIndexableKeys(keys);
|
||||||
|
Reference in New Issue
Block a user