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替换成你内置浏览器的包名即可