Android P 过GMS认证CDD检测项修改

博客介绍了系统内置浏览器的相关修改操作。一是将系统默认浏览器设为chrome,需在特定文件构造方法末尾、指定代码前添加内容;二是内置浏览器后,要将WEB_SEARCH调用修改为google的,需在另一文件中将特定包名替换为内置浏览器包名。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 系统内置两个浏览器,需要默认浏览器为chrome

frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java

在其构造方法末尾添加:

//weiyawei add start for default Browser
setDefaultBrowserPackageName("com.android.chrome",0);
//weiyawei add end for default Browser

在Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);之前加

2 内置浏览器之后WEB_SEARCH的调用也需要修改成google的

文件路径:

frameworks/base/core/java/com/android/internal/app/ResolverListController.java

@VisibleForTesting
    public List<ResolverActivity.ResolvedComponentInfo> getResolversForIntent(
            boolean shouldGetResolvedFilter,
            boolean shouldGetActivityMetadata,
            List<Intent> intents) {
        List<ResolverActivity.ResolvedComponentInfo> resolvedComponents = null;
        for (int i = 0, N = intents.size(); i < N; i++) {
            final Intent intent = intents.get(i);
            int flags = PackageManager.MATCH_DEFAULT_ONLY
                    | (shouldGetResolvedFilter ? PackageManager.GET_RESOLVED_FILTER : 0)
                    | (shouldGetActivityMetadata ? PackageManager.GET_META_DATA : 0);
            if (intent.isWebIntent()
                        || (intent.getFlags() & Intent.FLAG_ACTIVITY_MATCH_EXTERNAL) != 0) {
                flags |= PackageManager.MATCH_INSTANT;
            android.util.Log.i("weiyawei","intent.isWebIntent flags == " + flags);
            }
            final List<ResolveInfo> infos = mpm.queryIntentActivities(intent, flags);
            // Remove any activities that are not exported.
            int totalSize = infos.size();
            for (int j = totalSize - 1; j >= 0 ; j--) {
                ResolveInfo info = infos.get(j);
                android.util.Log.i("weiyawei","info.activityInfo.packageName == " + info.activityInfo.packageName);
                //weiyawei modify start
                if (info.activityInfo != null && !info.activityInfo.exported
                        || !TextUtils.isEmpty(intent.getAction()) && intent.getAction().equals("android.intent.action.WEB_SEARCH") &&
                           !TextUtils.isEmpty(info.activityInfo.packageName) && info.activityInfo.packageName.equals("com.opera.browser")) {
                    infos.remove(j);
                }
                //weiyawei modify end
//由于在CDD检测时通过adb命令发送指令,如果出现让用户选择的界面就会failed,所以目前采用屏蔽内置的这个浏览器的WEB_SEARCH
            }
            if (infos != null) {
                if (resolvedComponents == null) {
                    resolvedComponents = new ArrayList<>();
                }
                addResolveListDedupe(resolvedComponents, intent, infos);
            }
        }
        return resolvedComponents;
    }

 

将com.opera.browser替换成你内置浏览器的包名即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值