@VisibleForTesting static String buildUserAgentString(final Context context, final AmazonWebSettings settings, final String appName) {
final StringBuilder uaBuilder = new StringBuilder();
uaBuilder.append("Mozilla/5.0");
// WebView by default includes "; wv" as part of the platform string, but we're a full browser
// so we shouldn't include that.
// Most webview based browsers (and chrome), include the device name AND build ID, e.g.
// "Pixel XL Build/NOF26V", that seems unnecessary (and not great from a privacy perspective),
// so we skip that too.
uaBuilder.append(" (Linux; Android ").append(Build.VERSION.RELEASE).append(") ");
final String existingWebViewUA = settings.getUserAgentString();
final String appVersion;
try {
appVersion = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
// This should be impossible - we should always be able to get information about ourselves:
throw new IllegalStateException("Unable find package details for Focus", e);
}
final String focusToken = appName + "/" + appVersion;
uaBuilder.append(getUABrowserString(existingWebViewUA, focusToken));
return uaBuilder.toString();
}
WebViewProvider.java 文件源码
java
阅读 46
收藏 0
点赞 0
评论 0
项目:firefox-tv
作者:
评论列表
文章目录