Search in sources :

Example 51 with ResolveInfo

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

the class PreBootBroadcaster method sendNext.

public void sendNext() {
    if (mIndex >= mTargets.size()) {
        mHandler.obtainMessage(MSG_HIDE).sendToTarget();
        onFinished();
        return;
    }
    if (!mService.isUserRunning(mUserId, 0)) {
        Slog.i(TAG, "User " + mUserId + " is no longer running; skipping remaining receivers");
        mHandler.obtainMessage(MSG_HIDE).sendToTarget();
        onFinished();
        return;
    }
    if (!mQuiet) {
        mHandler.obtainMessage(MSG_SHOW, mTargets.size(), mIndex).sendToTarget();
    }
    final ResolveInfo ri = mTargets.get(mIndex++);
    final ComponentName componentName = ri.activityInfo.getComponentName();
    if (mProgress != null) {
        final CharSequence label = ri.activityInfo.loadLabel(mService.mContext.getPackageManager());
        mProgress.setProgress(mIndex, mTargets.size(), mService.mContext.getString(R.string.android_preparing_apk, label));
    }
    Slog.i(TAG, "Pre-boot of " + componentName.toShortString() + " for user " + mUserId);
    EventLogTags.writeAmPreBoot(mUserId, componentName.getPackageName());
    mIntent.setComponent(componentName);
    mService.broadcastIntentLocked(null, null, mIntent, null, this, 0, null, null, null, AppOpsManager.OP_NONE, null, true, false, ActivityManagerService.MY_PID, Process.SYSTEM_UID, mUserId);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ComponentName(android.content.ComponentName)

Example 52 with ResolveInfo

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

the class ActivityManagerService method collectReceiverComponents.

private List<ResolveInfo> collectReceiverComponents(Intent intent, String resolvedType, int callingUid, int[] users) {
    // TODO: come back and remove this assumption to triage all broadcasts
    int pmFlags = STOCK_PM_FLAGS | MATCH_DEBUG_TRIAGED_MISSING;
    List<ResolveInfo> receivers = null;
    try {
        HashSet<ComponentName> singleUserReceivers = null;
        boolean scannedFirstReceivers = false;
        for (int user : users) {
            // Shell broadcasts
            if (callingUid == Process.SHELL_UID && mUserController.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES, user) && !isPermittedShellBroadcast(intent)) {
                continue;
            }
            List<ResolveInfo> newReceivers = AppGlobals.getPackageManager().queryIntentReceivers(intent, resolvedType, pmFlags, user).getList();
            if (user != UserHandle.USER_SYSTEM && newReceivers != null) {
                // any receivers that should be filtered out.
                for (int i = 0; i < newReceivers.size(); i++) {
                    ResolveInfo ri = newReceivers.get(i);
                    if ((ri.activityInfo.flags & ActivityInfo.FLAG_SYSTEM_USER_ONLY) != 0) {
                        newReceivers.remove(i);
                        i--;
                    }
                }
            }
            if (newReceivers != null && newReceivers.size() == 0) {
                newReceivers = null;
            }
            if (receivers == null) {
                receivers = newReceivers;
            } else if (newReceivers != null) {
                // singleUser.
                if (!scannedFirstReceivers) {
                    // Collect any single user receivers we had already retrieved.
                    scannedFirstReceivers = true;
                    for (int i = 0; i < receivers.size(); i++) {
                        ResolveInfo ri = receivers.get(i);
                        if ((ri.activityInfo.flags & ActivityInfo.FLAG_SINGLE_USER) != 0) {
                            ComponentName cn = new ComponentName(ri.activityInfo.packageName, ri.activityInfo.name);
                            if (singleUserReceivers == null) {
                                singleUserReceivers = new HashSet<ComponentName>();
                            }
                            singleUserReceivers.add(cn);
                        }
                    }
                }
                // and de-dupping single user receivers.
                for (int i = 0; i < newReceivers.size(); i++) {
                    ResolveInfo ri = newReceivers.get(i);
                    if ((ri.activityInfo.flags & ActivityInfo.FLAG_SINGLE_USER) != 0) {
                        ComponentName cn = new ComponentName(ri.activityInfo.packageName, ri.activityInfo.name);
                        if (singleUserReceivers == null) {
                            singleUserReceivers = new HashSet<ComponentName>();
                        }
                        if (!singleUserReceivers.contains(cn)) {
                            singleUserReceivers.add(cn);
                            receivers.add(ri);
                        }
                    } else {
                        receivers.add(ri);
                    }
                }
            }
        }
    } catch (RemoteException ex) {
    // pm is in same process, this will never happen.
    }
    return receivers;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException) Point(android.graphics.Point) HashSet(java.util.HashSet)

Example 53 with ResolveInfo

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

the class InputManagerService method visitAllKeyboardLayouts.

private void visitAllKeyboardLayouts(KeyboardLayoutVisitor visitor) {
    final PackageManager pm = mContext.getPackageManager();
    Intent intent = new Intent(InputManager.ACTION_QUERY_KEYBOARD_LAYOUTS);
    for (ResolveInfo resolveInfo : pm.queryBroadcastReceivers(intent, PackageManager.GET_META_DATA | PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE)) {
        final ActivityInfo activityInfo = resolveInfo.activityInfo;
        final int priority = resolveInfo.priority;
        visitKeyboardLayoutsInPackage(pm, activityInfo, null, priority, visitor);
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) PackageManager(android.content.pm.PackageManager) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Example 54 with ResolveInfo

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

the class PackageManagerService method packageIsBrowser.

private boolean packageIsBrowser(String packageName, int userId) {
    List<ResolveInfo> list = queryIntentActivitiesInternal(sBrowserIntent, null, PackageManager.MATCH_ALL, userId);
    final int N = list.size();
    for (int i = 0; i < N; i++) {
        ResolveInfo info = list.get(i);
        if (packageName.equals(info.activityInfo.packageName)) {
            return true;
        }
    }
    return false;
}
Also used : EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo) ResolveInfo(android.content.pm.ResolveInfo)

Example 55 with ResolveInfo

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

the class PackageManagerService method queryIntentContentProvidersInternal.

@NonNull
private List<ResolveInfo> queryIntentContentProvidersInternal(Intent intent, String resolvedType, int flags, int userId) {
    if (!sUserManager.exists(userId))
        return Collections.emptyList();
    flags = updateFlagsForResolve(flags, userId, intent);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (intent.getSelector() != null) {
            intent = intent.getSelector();
            comp = intent.getComponent();
        }
    }
    if (comp != null) {
        final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        final ProviderInfo pi = getProviderInfo(comp, flags, userId);
        if (pi != null) {
            final ResolveInfo ri = new ResolveInfo();
            ri.providerInfo = pi;
            list.add(ri);
        }
        return list;
    }
    // reader
    synchronized (mPackages) {
        String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mProviders.queryIntent(intent, resolvedType, flags, userId);
        }
        final PackageParser.Package pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mProviders.queryIntentForPackage(intent, resolvedType, flags, pkg.providers, userId);
        }
        return Collections.emptyList();
    }
}
Also used : EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo) ResolveInfo(android.content.pm.ResolveInfo) ProviderInfo(android.content.pm.ProviderInfo) PackageParser(android.content.pm.PackageParser) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) NonNull(android.annotation.NonNull)

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