Search in sources :

Example 11 with DefaultAppInfo

use of com.android.settings.applications.defaultapps.DefaultAppInfo in project platform_packages_apps_Settings by BlissRoms.

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 12 with DefaultAppInfo

use of com.android.settings.applications.defaultapps.DefaultAppInfo in project platform_packages_apps_Settings by BlissRoms.

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 13 with DefaultAppInfo

use of com.android.settings.applications.defaultapps.DefaultAppInfo in project android_packages_apps_Settings by LineageOS.

the class ShortcutServicePickerFragment method getCandidates.

@Override
protected List<? extends DefaultAppInfo> getCandidates() {
    final AccessibilityManager accessibilityManager = getContext().getSystemService(AccessibilityManager.class);
    final List<AccessibilityServiceInfo> installedServices = accessibilityManager.getInstalledAccessibilityServiceList();
    final int numInstalledServices = installedServices.size();
    List<DefaultAppInfo> candidates = new ArrayList<>(numInstalledServices);
    for (int i = 0; i < numInstalledServices; i++) {
        AccessibilityServiceInfo installedServiceInfo = installedServices.get(i);
        candidates.add(new DefaultAppInfo(mPm, UserHandle.myUserId(), installedServiceInfo.getComponentName(), (String) installedServiceInfo.loadSummary(mPm.getPackageManager()), true));
    }
    return candidates;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) ArrayList(java.util.ArrayList) DefaultAppInfo(com.android.settings.applications.defaultapps.DefaultAppInfo)

Example 14 with DefaultAppInfo

use of com.android.settings.applications.defaultapps.DefaultAppInfo in project android_packages_apps_Settings by LineageOS.

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 15 with DefaultAppInfo

use of com.android.settings.applications.defaultapps.DefaultAppInfo in project android_packages_apps_Settings by LineageOS.

the class WebViewAppPickerTest method testEnabledPackageShowsEmptySummary.

@Test
public void testEnabledPackageShowsEmptySummary() {
    String disabledReason = null;
    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, never()).setSummary(any());
}
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)25 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)12 RadioButtonPreference (com.android.settings.widget.RadioButtonPreference)10 ResolveInfo (android.content.pm.ResolveInfo)6 VoiceInteractionServiceInfo (android.service.voice.VoiceInteractionServiceInfo)6 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)5 AccessibilityManager (android.view.accessibility.AccessibilityManager)5 ApplicationInfo (android.content.pm.ApplicationInfo)2 PackageInfo (android.content.pm.PackageInfo)2 PackageItemInfo (android.content.pm.PackageItemInfo)2 PackageManager (android.content.pm.PackageManager)2 TestConfig (com.android.settings.TestConfig)2 Config (org.robolectric.annotation.Config)2