Search in sources :

Example 1 with DefaultAppInfo

use of com.android.settingslib.applications.DefaultAppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DefaultAutofillPickerTest method getConfirmationMessage_shouldNotBeNull.

@Test
public void getConfirmationMessage_shouldNotBeNull() {
    mPicker.onAttach((Context) mActivity);
    final DefaultAppInfo info = mock(DefaultAppInfo.class);
    when(info.loadLabel()).thenReturn("test_app_name");
    assertThat(mPicker.getConfirmationMessage(info)).isNotNull();
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) Test(org.junit.Test)

Example 2 with DefaultAppInfo

use of com.android.settingslib.applications.DefaultAppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WebViewAppPickerTest method testDisabledPackageShowsDisabledReasonSummary.

@Test
public void testDisabledPackageShowsDisabledReasonSummary() {
    String disabledReason = "disabled";
    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)).setSummary(eq(disabledReason));
    // Ensure we haven't called setSummary several times.
    verify(preference, times(1)).setSummary(any());
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Example 3 with DefaultAppInfo

use of com.android.settingslib.applications.DefaultAppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Example 4 with DefaultAppInfo

use of com.android.settingslib.applications.DefaultAppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WebViewAppPickerTest method testDisabledPackageShownAsDisabled.

@Test
public void testDisabledPackageShownAsDisabled() {
    DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mContext.getPackageManager(), createApplicationInfo(PACKAGE_NAME), "disabled");
    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(false));
    verify(preference, never()).setEnabled(eq(true));
}
Also used : DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Test(org.junit.Test)

Example 5 with DefaultAppInfo

use of com.android.settingslib.applications.DefaultAppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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)

Aggregations

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