Search in sources :

Example 46 with DefaultAppInfo

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;
}
Also used : ArrayList(java.util.ArrayList) ApplicationInfo(android.content.pm.ApplicationInfo) DefaultAppInfo(com.android.settings.applications.defaultapps.DefaultAppInfo)

Example 47 with DefaultAppInfo

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);
}
Also used : DefaultAppInfo(com.android.settings.applications.defaultapps.DefaultAppInfo) Test(org.junit.Test) Config(org.robolectric.annotation.Config) TestConfig(com.android.settings.TestConfig)

Example 48 with DefaultAppInfo

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());
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) PackageItemInfo(android.content.pm.PackageItemInfo) DefaultAppInfo(com.android.settings.applications.defaultapps.DefaultAppInfo) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Example 49 with DefaultAppInfo

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());
}
Also used : DefaultAppInfo(com.android.settings.applications.defaultapps.DefaultAppInfo) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Example 50 with DefaultAppInfo

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));
}
Also used : DefaultAppInfo(com.android.settings.applications.defaultapps.DefaultAppInfo) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Aggregations

DefaultAppInfo (com.android.settings.applications.defaultapps.DefaultAppInfo)54 Test (org.junit.Test)36 RadioButtonPreference (com.android.settings.widget.RadioButtonPreference)30 ArrayList (java.util.ArrayList)18 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)6 ApplicationInfo (android.content.pm.ApplicationInfo)6 PackageInfo (android.content.pm.PackageInfo)6 PackageItemInfo (android.content.pm.PackageItemInfo)6 PackageManager (android.content.pm.PackageManager)6 ResolveInfo (android.content.pm.ResolveInfo)6 VoiceInteractionServiceInfo (android.service.voice.VoiceInteractionServiceInfo)6 AccessibilityManager (android.view.accessibility.AccessibilityManager)6 TestConfig (com.android.settings.TestConfig)6 Config (org.robolectric.annotation.Config)6