use of com.android.settings.applications.defaultapps.DefaultAppInfo in project android_packages_apps_Settings by SudaMod.
the class WebViewAppPicker method getCandidates.
@Override
protected List<DefaultAppInfo> getCandidates() {
final List<DefaultAppInfo> packageInfoList = new ArrayList<DefaultAppInfo>();
List<ApplicationInfo> pkgs = getWebViewUpdateServiceWrapper().getValidWebViewApplicationInfos(getContext());
for (ApplicationInfo ai : pkgs) {
packageInfoList.add(createDefaultAppInfo(mPm, ai, getDisabledReason(getWebViewUpdateServiceWrapper(), getContext(), ai.packageName)));
}
return packageInfoList;
}
use of com.android.settings.applications.defaultapps.DefaultAppInfo in project android_packages_apps_Settings by SudaMod.
the class DefaultAssistPreferenceControllerTest method getDefaultAppInfo_hasDefaultAssist_shouldReturnKey.
@Test
@Config(shadows = { ShadowSecureSettings.class })
public void getDefaultAppInfo_hasDefaultAssist_shouldReturnKey() {
final String flattenKey = "com.android.settings/assist";
Settings.Secure.putString(null, Settings.Secure.ASSISTANT, flattenKey);
DefaultAppInfo appInfo = mController.getDefaultAppInfo();
assertThat(appInfo.getKey()).isEqualTo(flattenKey);
}
use of com.android.settings.applications.defaultapps.DefaultAppInfo in project android_packages_apps_Settings by SudaMod.
the class WebViewAppPickerTest method testWebViewVersionAddedAfterLabel.
/**
* Ensure that the version name of a WebView package is displayed after its name in the
* preference title.
*/
@Test
public void testWebViewVersionAddedAfterLabel() throws PackageManager.NameNotFoundException {
PackageItemInfo mockPackageItemInfo = mock(PackageItemInfo.class);
mockPackageItemInfo.packageName = DEFAULT_PACKAGE_NAME;
when(mockPackageItemInfo.loadLabel(any())).thenReturn("myPackage");
DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mPackageManager, mockPackageItemInfo, "");
PackageInfo packageInfo = new PackageInfo();
packageInfo.versionName = "myVersionName";
PackageManager pm = mock(PackageManager.class);
when(pm.getPackageInfo(eq(DEFAULT_PACKAGE_NAME), anyInt())).thenReturn(packageInfo);
when(mPackageManager.getPackageManager()).thenReturn(pm);
RadioButtonPreference mockPreference = mock(RadioButtonPreference.class);
mPicker.bindPreference(mockPreference, DEFAULT_PACKAGE_NAME, webviewAppInfo, null);
mPicker.bindPreferenceExtra(mockPreference, DEFAULT_PACKAGE_NAME, webviewAppInfo, null, null);
verify(mockPreference, times(1)).setTitle(eq("myPackage myVersionName"));
verify(mockPreference, times(1)).setTitle(any());
}
use of com.android.settings.applications.defaultapps.DefaultAppInfo in project android_packages_apps_Settings by SudaMod.
the class WebViewAppPickerTest method testDisabledPackageShowsDisabledReasonSummary.
@Test
public void testDisabledPackageShowsDisabledReasonSummary() {
String disabledReason = "disabled";
DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mPackageManager, createApplicationInfo(DEFAULT_PACKAGE_NAME), disabledReason);
RadioButtonPreference mockPreference = mock(RadioButtonPreference.class);
mPicker.bindPreference(mockPreference, DEFAULT_PACKAGE_NAME, webviewAppInfo, null);
mPicker.bindPreferenceExtra(mockPreference, DEFAULT_PACKAGE_NAME, webviewAppInfo, null, null);
verify(mockPreference, times(1)).setSummary(eq(disabledReason));
// Ensure we haven't called setSummary several times.
verify(mockPreference, times(1)).setSummary(any());
}
use of com.android.settings.applications.defaultapps.DefaultAppInfo in project android_packages_apps_Settings by SudaMod.
the class WebViewAppPickerTest method testEnabledPackageShownAsEnabled.
@Test
public void testEnabledPackageShownAsEnabled() {
String disabledReason = "";
DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mPackageManager, createApplicationInfo(DEFAULT_PACKAGE_NAME), disabledReason);
RadioButtonPreference mockPreference = mock(RadioButtonPreference.class);
mPicker.bindPreference(mockPreference, DEFAULT_PACKAGE_NAME, webviewAppInfo, null);
mPicker.bindPreferenceExtra(mockPreference, DEFAULT_PACKAGE_NAME, webviewAppInfo, null, null);
verify(mockPreference, times(1)).setEnabled(eq(true));
verify(mockPreference, never()).setEnabled(eq(false));
}
Aggregations