-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Make the UserAgent class a Singleton #21794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Generated by 🚫 Danger |
|
App Name | ![]() |
|
Flavor | Jalapeno | |
Build Type | Debug | |
Version | pr21794-33637e5 | |
Commit | 33637e5 | |
Direct Download | jetpack-prototype-build-pr21794-33637e5.apk |
|
App Name | ![]() |
|
Flavor | Jalapeno | |
Build Type | Debug | |
Version | pr21794-33637e5 | |
Commit | 33637e5 | |
Direct Download | wordpress-prototype-build-pr21794-33637e5.apk |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## trunk #21794 +/- ##
=======================================
Coverage 39.32% 39.32%
=======================================
Files 2125 2125
Lines 99871 99871
Branches 15385 15385
=======================================
Hits 39277 39277
Misses 57114 57114
Partials 3480 3480 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I verified the user agent sent in Reader requests matched before and after these changes.
This small PR changes the
UserAgent
class to a singleton and uses a privatesetter
for the user agent string. This was initially done as part of #21681, which retrieved the default user agent in the background, but after discussion it was decided this could cause more problems than it solves.Note the reason for the previous PR was there is some overhead to calling
WebSettings.getDefaultUserAgent()
because as described here, the first time that's called requires loadingWebView
code. This PR doesn't address that overhead, but making the class a singleton gets us a step closer.Also note avoiding calling
WebSettings.getDefaultUserAgent()
at startup so the delay isn't so noticeable isn't a solution since we set the user agent for ourRestClientUtils
here.I'm not sure of testing steps, other than to verify that the correct user agent is being returned.