@Test public void testGetUserAgent() throws Exception { assertTrue(target.getUserAgent().contains("ChannelSDK/" + SDK_VERSION)); }
@NonNull public String getUserAgent() { if (cachedUserAgent != null) { return cachedUserAgent; } String packageName = packageInfo == null ? DEFAULT_PACKAGE_NAME : packageInfo.packageName; String versionName = packageInfo == null ? DEFAULT_VERSION_NAME : packageInfo.versionName; Locale locale = Locale.getDefault(); cachedUserAgent = packageName + "/" + versionName + " ChannelSDK/" + sdkVersion + " (Linux; U; Android " + Build.VERSION.RELEASE + "; " + locale.getLanguage() + "-" + locale.getCountry() + "; " + Build.MODEL + " Build/" + Build.ID + ")"; return cachedUserAgent; }
UserAgentGenerator { @NonNull public String getUserAgent() { if (cachedUserAgent != null) { return cachedUserAgent; } String packageName = packageInfo == null ? DEFAULT_PACKAGE_NAME : packageInfo.packageName; String versionName = packageInfo == null ? DEFAULT_VERSION_NAME : packageInfo.versionName; Locale locale = Locale.getDefault(); cachedUserAgent = packageName + "/" + versionName + " ChannelSDK/" + sdkVersion + " (Linux; U; Android " + Build.VERSION.RELEASE + "; " + locale.getLanguage() + "-" + locale.getCountry() + "; " + Build.MODEL + " Build/" + Build.ID + ")"; return cachedUserAgent; } }
UserAgentGenerator { @NonNull public String getUserAgent() { if (cachedUserAgent != null) { return cachedUserAgent; } String packageName = packageInfo == null ? DEFAULT_PACKAGE_NAME : packageInfo.packageName; String versionName = packageInfo == null ? DEFAULT_VERSION_NAME : packageInfo.versionName; Locale locale = Locale.getDefault(); cachedUserAgent = packageName + "/" + versionName + " ChannelSDK/" + sdkVersion + " (Linux; U; Android " + Build.VERSION.RELEASE + "; " + locale.getLanguage() + "-" + locale.getCountry() + "; " + Build.MODEL + " Build/" + Build.ID + ")"; return cachedUserAgent; } UserAgentGenerator(@NonNull Context context, @NonNull String sdkVersion); }
UserAgentGenerator { @NonNull public String getUserAgent() { if (cachedUserAgent != null) { return cachedUserAgent; } String packageName = packageInfo == null ? DEFAULT_PACKAGE_NAME : packageInfo.packageName; String versionName = packageInfo == null ? DEFAULT_VERSION_NAME : packageInfo.versionName; Locale locale = Locale.getDefault(); cachedUserAgent = packageName + "/" + versionName + " ChannelSDK/" + sdkVersion + " (Linux; U; Android " + Build.VERSION.RELEASE + "; " + locale.getLanguage() + "-" + locale.getCountry() + "; " + Build.MODEL + " Build/" + Build.ID + ")"; return cachedUserAgent; } UserAgentGenerator(@NonNull Context context, @NonNull String sdkVersion); @NonNull String getUserAgent(); }
UserAgentGenerator { @NonNull public String getUserAgent() { if (cachedUserAgent != null) { return cachedUserAgent; } String packageName = packageInfo == null ? DEFAULT_PACKAGE_NAME : packageInfo.packageName; String versionName = packageInfo == null ? DEFAULT_VERSION_NAME : packageInfo.versionName; Locale locale = Locale.getDefault(); cachedUserAgent = packageName + "/" + versionName + " ChannelSDK/" + sdkVersion + " (Linux; U; Android " + Build.VERSION.RELEASE + "; " + locale.getLanguage() + "-" + locale.getCountry() + "; " + Build.MODEL + " Build/" + Build.ID + ")"; return cachedUserAgent; } UserAgentGenerator(@NonNull Context context, @NonNull String sdkVersion); @NonNull String getUserAgent();  }