Search in sources :

Example 71 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class PackageManagerShellCommand method runQueryIntentServices.

private int runQueryIntentServices() {
    Intent intent;
    try {
        intent = parseIntentAndUser();
    } catch (URISyntaxException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
    try {
        List<ResolveInfo> result = mInterface.queryIntentServices(intent, null, 0, mTargetUser).getList();
        PrintWriter pw = getOutPrintWriter();
        if (result == null || result.size() <= 0) {
            pw.println("No services found");
        } else {
            if (!mComponents) {
                pw.print(result.size());
                pw.println(" services found:");
                PrintWriterPrinter pr = new PrintWriterPrinter(pw);
                for (int i = 0; i < result.size(); i++) {
                    pw.print("  Service #");
                    pw.print(i);
                    pw.println(":");
                    printResolveInfo(pr, "    ", result.get(i), mBrief, mComponents);
                }
            } else {
                PrintWriterPrinter pr = new PrintWriterPrinter(pw);
                for (int i = 0; i < result.size(); i++) {
                    printResolveInfo(pr, "", result.get(i), mBrief, mComponents);
                }
            }
        }
    } catch (RemoteException e) {
        throw new RuntimeException("Failed calling service", e);
    }
    return 0;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PrintWriterPrinter(android.util.PrintWriterPrinter) Intent(android.content.Intent) URISyntaxException(java.net.URISyntaxException) RemoteException(android.os.RemoteException) PrintWriter(java.io.PrintWriter)

Example 72 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class InputMethodSubtypeSwitchingControllerTest method addDummyImeSubtypeListItems.

private static void addDummyImeSubtypeListItems(List<ImeSubtypeListItem> items, String imeName, String imeLabel, List<String> subtypeLocales, boolean supportsSwitchingToNextInputMethod) {
    final ResolveInfo ri = new ResolveInfo();
    final ServiceInfo si = new ServiceInfo();
    final ApplicationInfo ai = new ApplicationInfo();
    ai.packageName = DUMMY_PACKAGE_NAME;
    ai.enabled = true;
    si.applicationInfo = ai;
    si.enabled = true;
    si.packageName = DUMMY_PACKAGE_NAME;
    si.name = imeName;
    si.exported = true;
    si.nonLocalizedLabel = imeLabel;
    ri.serviceInfo = si;
    List<InputMethodSubtype> subtypes = null;
    if (subtypeLocales != null) {
        subtypes = new ArrayList<>();
        for (String subtypeLocale : subtypeLocales) {
            subtypes.add(createDummySubtype(subtypeLocale));
        }
    }
    final InputMethodInfo imi = new InputMethodInfo(ri, DUMMY_IS_AUX_IME, DUMMY_SETTING_ACTIVITY_NAME, subtypes, DUMMY_IS_DEFAULT_RES_ID, DUMMY_FORCE_DEFAULT, supportsSwitchingToNextInputMethod);
    if (subtypes == null) {
        items.add(new ImeSubtypeListItem(imeName, null, /* variableName */
        imi, NOT_A_SUBTYPE_ID, null, SYSTEM_LOCALE));
    } else {
        for (int i = 0; i < subtypes.size(); ++i) {
            final String subtypeLocale = subtypeLocales.get(i);
            items.add(new ImeSubtypeListItem(imeName, subtypeLocale, imi, i, subtypeLocale, SYSTEM_LOCALE));
        }
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) ApplicationInfo(android.content.pm.ApplicationInfo) InputMethodInfo(android.view.inputmethod.InputMethodInfo) ImeSubtypeListItem(com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem)

Example 73 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class RecentsProvider method call.

@Override
public Bundle call(String method, String arg, Bundle extras) {
    if (METHOD_PURGE.equals(method)) {
        // Purge references to unknown authorities
        final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
        final Set<String> knownAuth = Sets.newHashSet();
        for (ResolveInfo info : getContext().getPackageManager().queryIntentContentProviders(intent, 0)) {
            knownAuth.add(info.providerInfo.authority);
        }
        purgeByAuthority(new Predicate<String>() {

            @Override
            public boolean test(String authority) {
                // Purge unknown authorities
                return !knownAuth.contains(authority);
            }
        });
        return null;
    } else if (METHOD_PURGE_PACKAGE.equals(method)) {
        // Purge references to authorities in given package
        final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
        intent.setPackage(arg);
        final Set<String> packageAuth = Sets.newHashSet();
        for (ResolveInfo info : getContext().getPackageManager().queryIntentContentProviders(intent, 0)) {
            packageAuth.add(info.providerInfo.authority);
        }
        if (!packageAuth.isEmpty()) {
            purgeByAuthority(new Predicate<String>() {

                @Override
                public boolean test(String authority) {
                    // Purge authority matches
                    return packageAuth.contains(authority);
                }
            });
        }
        return null;
    } else {
        return super.call(method, arg, extras);
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Set(java.util.Set) Intent(android.content.Intent) DocumentInfo.getCursorString(com.android.documentsui.model.DocumentInfo.getCursorString) Predicate(java.util.function.Predicate)

Example 74 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class FilesAppPerfTest method killProviders.

private void killProviders() throws Exception {
    final Context context = getInstrumentation().getContext();
    final PackageManager pm = context.getPackageManager();
    final ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
    final List<ResolveInfo> providers = pm.queryIntentContentProviders(intent, 0);
    for (ResolveInfo info : providers) {
        final String packageName = info.providerInfo.packageName;
        am.killBackgroundProcesses(packageName);
    }
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) ActivityManager(android.app.ActivityManager)

Example 75 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class AppWidgetServiceImpl method loadGroupWidgetProvidersLocked.

private void loadGroupWidgetProvidersLocked(int[] profileIds) {
    List<ResolveInfo> allReceivers = null;
    Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
    final int profileCount = profileIds.length;
    for (int i = 0; i < profileCount; i++) {
        final int profileId = profileIds[i];
        List<ResolveInfo> receivers = queryIntentReceivers(intent, profileId);
        if (receivers != null && !receivers.isEmpty()) {
            if (allReceivers == null) {
                allReceivers = new ArrayList<>();
            }
            allReceivers.addAll(receivers);
        }
    }
    final int N = (allReceivers == null) ? 0 : allReceivers.size();
    for (int i = 0; i < N; i++) {
        ResolveInfo receiver = allReceivers.get(i);
        addProviderLocked(receiver);
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Point(android.graphics.Point)

Aggregations

ResolveInfo (android.content.pm.ResolveInfo)1211 Intent (android.content.Intent)760 PackageManager (android.content.pm.PackageManager)470 ComponentName (android.content.ComponentName)375 ActivityInfo (android.content.pm.ActivityInfo)209 ArrayList (java.util.ArrayList)205 PendingIntent (android.app.PendingIntent)159 RemoteException (android.os.RemoteException)137 ServiceInfo (android.content.pm.ServiceInfo)120 ApplicationInfo (android.content.pm.ApplicationInfo)73 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)58 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)53 Bundle (android.os.Bundle)47 HashMap (java.util.HashMap)46 IOException (java.io.IOException)43 HashSet (java.util.HashSet)43 Point (android.graphics.Point)42 ActivityNotFoundException (android.content.ActivityNotFoundException)38 PackageInfo (android.content.pm.PackageInfo)37 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)33