WebViewProvider.java 文件源码

java
阅读 46 收藏 0 点赞 0 评论 0

项目:firefox-tv 作者:
@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();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号