chooseBestActivity HOME

ActivityManagerService
startHomeActivityLocked
resolveActivityInfo

PackageManagerService

resolveIntent

resolveIntentWithPackage

private ResolveInfo chooseBestActivity(Intent intent, String resolvedType,
        int flags, List<ResolveInfo> query, int userId) {
    if (query != null) {
        final int N = query.size();
        if (N == 1) {
            return query.get(0);
        } else if (N > 1) {
            final boolean debug = ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
            // If there is more than one activity with the same priority,
            // then let the user decide between them.
            ResolveInfo r0 = query.get(0);
            ResolveInfo r1 = query.get(1);
            if (DEBUG_INTENT_MATCHING || debug) {
                Slog.v(TAG, r0.activityInfo.name + "=" + r0.priority + " vs "
                        + r1.activityInfo.name + "=" + r1.priority);
            }
            // If the first activity has a higher priority, or a different
            // default, then it is always desireable to pick it.
            if (r0.priority != r1.priority
                    || r0.preferredOrder != r1.preferredOrder
                    || r0.isDefault != r1.isDefault) {
                return query.get(0);
            }
           
            // If we have saved a preference for a preferred activity for
            // this Intent, use that.
            ResolveInfo ri = findPreferredActivity(intent, resolvedType,
                    flags, query, r0.priority, true, false, debug, userId);
            if (ri != null) {
                return ri;
            }
            if (userId != 0) {
                ri = new ResolveInfo(mResolveInfo);
                ri.activityInfo = new ActivityInfo(ri.activityInfo);
                ri.activityInfo.applicationInfo = new ApplicationInfo(
                        ri.activityInfo.applicationInfo);
                ri.activityInfo.applicationInfo.uid = UserHandle.getUid(userId,
                        UserHandle.getAppId(ri.activityInfo.applicationInfo.uid));
                return ri;
            }
            return mResolveInfo;
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值