Search in sources :

Example 21 with DefaultAppInfo

use of com.android.settingslib.applications.DefaultAppInfo in project android_packages_apps_Settings by omnirom.

the class DefaultAutofillPicker method getCandidates.

@Override
protected List<DefaultAppInfo> getCandidates() {
    final List<DefaultAppInfo> candidates = new ArrayList<>();
    final List<ResolveInfo> resolveInfos = mPm.queryIntentServicesAsUser(AUTOFILL_PROBE, PackageManager.GET_META_DATA, mUserId);
    final Context context = getContext();
    for (ResolveInfo info : resolveInfos) {
        final String permission = info.serviceInfo.permission;
        if (Manifest.permission.BIND_AUTOFILL_SERVICE.equals(permission)) {
            candidates.add(new DefaultAppInfo(context, mPm, mUserId, new ComponentName(info.serviceInfo.packageName, info.serviceInfo.name)));
        }
        if (Manifest.permission.BIND_AUTOFILL.equals(permission)) {
            // Let it go for now...
            Log.w(TAG, "AutofillService from '" + info.serviceInfo.packageName + "' uses unsupported permission " + Manifest.permission.BIND_AUTOFILL + ". It works for now, but might not be supported on future releases");
            candidates.add(new DefaultAppInfo(context, mPm, mUserId, new ComponentName(info.serviceInfo.packageName, info.serviceInfo.name)));
        }
    }
    return candidates;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Context(android.content.Context) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo)

Example 22 with DefaultAppInfo

use of com.android.settingslib.applications.DefaultAppInfo in project android_packages_apps_Settings by omnirom.

the class WebViewAppPickerTest method testEnabledPackageShowsEmptySummary.

@Test
public void testEnabledPackageShowsEmptySummary() {
    DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mContext.getPackageManager(), createApplicationInfo(PACKAGE_NAME), null);
    RadioButtonPreference preference = mock(RadioButtonPreference.class);
    mPicker.bindPreference(preference, PACKAGE_NAME, webviewAppInfo, null);
    mPicker.bindPreferenceExtra(preference, PACKAGE_NAME, webviewAppInfo, null, null);
    verify(preference, never()).setSummary(any());
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Test(org.junit.Test)

Example 23 with DefaultAppInfo

use of com.android.settingslib.applications.DefaultAppInfo in project android_packages_apps_Settings by omnirom.

the class WebViewAppPickerTest method testEnabledPackageShownAsEnabled.

@Test
public void testEnabledPackageShownAsEnabled() {
    String disabledReason = "";
    DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mContext.getPackageManager(), createApplicationInfo(PACKAGE_NAME), disabledReason);
    RadioButtonPreference preference = mock(RadioButtonPreference.class);
    mPicker.bindPreference(preference, PACKAGE_NAME, webviewAppInfo, null);
    mPicker.bindPreferenceExtra(preference, PACKAGE_NAME, webviewAppInfo, null, null);
    verify(preference, times(1)).setEnabled(eq(true));
    verify(preference, never()).setEnabled(eq(false));
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Test(org.junit.Test)

Aggregations

DefaultAppInfo (com.android.settingslib.applications.DefaultAppInfo)23 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)7 Context (android.content.Context)5 RadioButtonPreference (com.android.settings.widget.RadioButtonPreference)5 RadioButtonPreference (com.android.settingslib.widget.RadioButtonPreference)5 ComponentName (android.content.ComponentName)4 ApplicationInfo (android.content.pm.ApplicationInfo)3 PackageItemInfo (android.content.pm.PackageItemInfo)2 ResolveInfo (android.content.pm.ResolveInfo)2 ServiceInfo (android.content.pm.ServiceInfo)2 CandidateInfo (com.android.settingslib.widget.CandidateInfo)2 Config (org.robolectric.annotation.Config)2 Pair (android.util.Pair)1 TwoTargetPreference (com.android.settingslib.TwoTargetPreference)1 TwoTargetPreference (com.android.settingslib.widget.TwoTargetPreference)1