use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by SudaMod.
the class NetworkScorerPickerPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
final List<NetworkScorerAppData> allValidScorers = mNetworkScoreManager.getAllValidScorers();
boolean enabled = !allValidScorers.isEmpty();
preference.setEnabled(enabled);
if (!enabled) {
preference.setSummary(null);
return;
}
NetworkScorerAppData scorer = mNetworkScoreManager.getActiveScorer();
if (scorer == null) {
preference.setSummary(mContext.getString(R.string.network_scorer_picker_none_preference));
} else {
preference.setSummary(scorer.getRecommendationServiceLabel());
}
}
use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by SudaMod.
the class NetworkScorerPickerPreferenceControllerTest method updateState_scorersAvailable_preferenceEnabled.
@Test
public void updateState_scorersAvailable_preferenceEnabled() {
ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE, TEST_SCORER_CLASS);
NetworkScorerAppData scorerAppData = new NetworkScorerAppData(0, scorer, TEST_SCORER_LABEL, null, /* enableUseOpenWifiActivity */
null);
when(mNetworkScorer.getAllValidScorers()).thenReturn(Collections.singletonList(scorerAppData));
Preference preference = mock(Preference.class);
mController.updateState(preference);
verify(preference).setEnabled(true);
}
use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by SudaMod.
the class NetworkScorerPickerPreferenceControllerTest method updateState_preferenceSetSummaryAsActiveScorerLabel.
@Test
public void updateState_preferenceSetSummaryAsActiveScorerLabel() {
ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE, TEST_SCORER_CLASS);
NetworkScorerAppData scorerAppData = new NetworkScorerAppData(0, scorer, TEST_SCORER_LABEL, null, /* enableUseOpenWifiActivity */
null);
when(mNetworkScorer.getAllValidScorers()).thenReturn(Collections.singletonList(scorerAppData));
when(mNetworkScorer.getActiveScorer()).thenReturn(scorerAppData);
Preference preference = mock(Preference.class);
mController.updateState(preference);
verify(preference).setSummary(TEST_SCORER_LABEL);
}
use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by SudaMod.
the class NetworkScorerPickerTest method testUpdateCandidates_validScorers_noActiveScorer.
@Test
public void testUpdateCandidates_validScorers_noActiveScorer() {
ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE_1, TEST_SCORER_CLASS_1);
NetworkScorerAppData scorerAppData = new NetworkScorerAppData(0, scorer, TEST_SCORER_LABEL_1, null, /* enableUseOpenWifiActivity */
null);
when(mNetworkScoreManager.getAllValidScorers()).thenReturn(Lists.newArrayList(scorerAppData));
when(mNetworkScoreManager.getActiveScorerPackage()).thenReturn(null);
ArgumentCaptor<RadioButtonPreference> arg = ArgumentCaptor.forClass(RadioButtonPreference.class);
mFragment.updateCandidates();
verify(mPreferenceScreen, times(2)).addPreference(arg.capture());
final RadioButtonPreference nonePref = arg.getAllValues().get(0);
assertThat(nonePref.getKey()).isNull();
assertThat(nonePref.isChecked()).isTrue();
final RadioButtonPreference testScorerPref = arg.getAllValues().get(1);
assertThat(testScorerPref.getTitle()).isEqualTo(TEST_SCORER_LABEL_1);
assertThat(testScorerPref.isChecked()).isFalse();
}
use of android.net.NetworkScorerAppData in project android_packages_apps_Settings by SudaMod.
the class UseOpenWifiPreferenceController method checkForFeatureSupportedScorers.
private void checkForFeatureSupportedScorers() {
if (mEnableUseWifiComponentName != null) {
mDoFeatureSupportedScorersExist = true;
return;
}
List<NetworkScorerAppData> scorers = mNetworkScoreManagerWrapper.getAllValidScorers();
for (NetworkScorerAppData scorer : scorers) {
if (scorer.getEnableUseOpenWifiActivity() != null) {
mDoFeatureSupportedScorersExist = true;
return;
}
}
mDoFeatureSupportedScorersExist = false;
}
Aggregations