Search in sources :

Example 6 with DefaultAppInfo

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

the class DefaultAssistPicker method getCandidates.

@Override
protected List<DefaultAppInfo> getCandidates() {
    mAvailableAssistants.clear();
    addAssistServices();
    addAssistActivities();
    final List<String> packages = new ArrayList<>();
    final List<DefaultAppInfo> candidates = new ArrayList<>();
    for (Info info : mAvailableAssistants) {
        final String packageName = info.component.getPackageName();
        if (packages.contains(packageName)) {
            // A service appears before an activity thus overrides it if from the same package.
            continue;
        }
        packages.add(packageName);
        candidates.add(new DefaultAppInfo(mPm, mUserId, info.component));
    }
    return candidates;
}
Also used : ArrayList(java.util.ArrayList) ResolveInfo(android.content.pm.ResolveInfo) VoiceInteractionServiceInfo(android.service.voice.VoiceInteractionServiceInfo) DefaultAppInfo(com.android.settings.applications.defaultapps.DefaultAppInfo) DefaultAppInfo(com.android.settings.applications.defaultapps.DefaultAppInfo)

Example 7 with DefaultAppInfo

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

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

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

the class DefaultAssistPicker method getCandidates.

@Override
protected List<DefaultAppInfo> getCandidates() {
    mAvailableAssistants.clear();
    addAssistServices();
    addAssistActivities();
    final List<String> packages = new ArrayList<>();
    final List<DefaultAppInfo> candidates = new ArrayList<>();
    for (Info info : mAvailableAssistants) {
        final String packageName = info.component.getPackageName();
        if (packages.contains(packageName)) {
            // A service appears before an activity thus overrides it if from the same package.
            continue;
        }
        packages.add(packageName);
        candidates.add(new DefaultAppInfo(mPm, mUserId, info.component));
    }
    return candidates;
}
Also used : ArrayList(java.util.ArrayList) ResolveInfo(android.content.pm.ResolveInfo) VoiceInteractionServiceInfo(android.service.voice.VoiceInteractionServiceInfo) DefaultAppInfo(com.android.settings.applications.defaultapps.DefaultAppInfo) DefaultAppInfo(com.android.settings.applications.defaultapps.DefaultAppInfo)

Example 9 with DefaultAppInfo

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

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

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

the class WebViewAppPickerTest method testDisabledPackageShownAsDisabled.

@Test
public void testDisabledPackageShownAsDisabled() {
    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)).setEnabled(eq(false));
    verify(mockPreference, never()).setEnabled(eq(true));
}
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