Search in sources :

Example 6 with DefaultAppInfo

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

the class NotificationAssistantPicker method onServicesReloaded.

@Override
public void onServicesReloaded(List<ServiceInfo> services) {
    List<CandidateInfo> list = new ArrayList<>();
    services.sort(new PackageItemInfo.DisplayNameComparator(mPm));
    for (ServiceInfo service : services) {
        if (mContext.getPackageManager().checkPermission(android.Manifest.permission.REQUEST_NOTIFICATION_ASSISTANT_SERVICE, service.packageName) == PackageManager.PERMISSION_GRANTED) {
            final ComponentName cn = new ComponentName(service.packageName, service.name);
            list.add(new DefaultAppInfo(mContext, mPm, mUserId, cn));
        }
    }
    list.add(new CandidateNone(mContext));
    mCandidateInfos = list;
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) CandidateInfo(com.android.settingslib.widget.CandidateInfo) ArrayList(java.util.ArrayList) PackageItemInfo(android.content.pm.PackageItemInfo) ComponentName(android.content.ComponentName) DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo)

Example 7 with DefaultAppInfo

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

the class WebViewAppPicker method getCandidates.

@Override
protected List<DefaultAppInfo> getCandidates() {
    final List<DefaultAppInfo> packageInfoList = new ArrayList<DefaultAppInfo>();
    final Context context = getContext();
    final WebViewUpdateServiceWrapper webViewUpdateService = getWebViewUpdateServiceWrapper();
    final List<ApplicationInfo> pkgs = webViewUpdateService.getValidWebViewApplicationInfos(context);
    for (ApplicationInfo ai : pkgs) {
        packageInfoList.add(createDefaultAppInfo(context, mPm, ai, getDisabledReason(webViewUpdateService, context, ai.packageName)));
    }
    return packageInfoList;
}
Also used : Context(android.content.Context) ArrayList(java.util.ArrayList) ApplicationInfo(android.content.pm.ApplicationInfo) DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo)

Example 8 with DefaultAppInfo

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

the class BugReportHandlerPicker method getCandidates.

@Override
protected List<DefaultAppInfo> getCandidates() {
    final Context context = getContext();
    final List<Pair<ApplicationInfo, Integer>> validBugReportHandlerInfos = getBugReportHandlerUtil().getValidBugReportHandlerInfos(context);
    final List<DefaultAppInfo> candidates = new ArrayList<>();
    for (Pair<ApplicationInfo, Integer> info : validBugReportHandlerInfos) {
        candidates.add(createDefaultAppInfo(context, mPm, info.second, info.first));
    }
    return candidates;
}
Also used : Context(android.content.Context) ArrayList(java.util.ArrayList) ApplicationInfo(android.content.pm.ApplicationInfo) DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo) Pair(android.util.Pair)

Example 9 with DefaultAppInfo

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

the class WebViewAppPicker method getCandidates.

@Override
protected List<DefaultAppInfo> getCandidates() {
    final List<DefaultAppInfo> packageInfoList = new ArrayList<DefaultAppInfo>();
    final Context context = getContext();
    final WebViewUpdateServiceWrapper webViewUpdateService = getWebViewUpdateServiceWrapper();
    final List<ApplicationInfo> pkgs = webViewUpdateService.getValidWebViewApplicationInfos(context);
    for (ApplicationInfo ai : pkgs) {
        packageInfoList.add(createDefaultAppInfo(context, mPm, ai, getDisabledReason(webViewUpdateService, context, ai.packageName)));
    }
    return packageInfoList;
}
Also used : Context(android.content.Context) ArrayList(java.util.ArrayList) ApplicationInfo(android.content.pm.ApplicationInfo) DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo)

Example 10 with DefaultAppInfo

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

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() {
    final DefaultAppInfo webviewAppInfo = mPicker.createDefaultAppInfo(mContext, mContext.getPackageManager(), createApplicationInfo(PACKAGE_NAME), "");
    final RadioButtonPreference mockPreference = mock(RadioButtonPreference.class);
    mPicker.bindPreference(mockPreference, PACKAGE_NAME, webviewAppInfo, null);
    mPicker.bindPreferenceExtra(mockPreference, PACKAGE_NAME, webviewAppInfo, null, null);
    verify(mockPreference).setTitle(eq(PACKAGE_NAME + " " + PACKAGE_VERSION));
    verify(mockPreference).setTitle(any());
}
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