Skip to content
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

Workaround for Strict mode Untagged Socket issue #443

Merged
merged 2 commits into from
Dec 16, 2019

Conversation

harvsu
Copy link
Contributor

@harvsu harvsu commented Dec 6, 2019

Untagged socket detection is one of the anomalies detected by Strict Mode in android from Android O. Since the Telemetry Test app enables the Strict mode with penalty death in debug mode, the app crashes/freezes on installation.
Strict mode expects a tag set to every thread and the threads created by Okhttp sockets does not not seem to do so for different reason. This is still an open issue
square/okhttp#3537

This pull request adds custom socket factory and sets TrafficStats.setThreadStatsTag(1000) for configuration client(okhttpClient). The main Telemetry Client has the similar workaround that already in place.

@harvsu
Copy link
Contributor Author

harvsu commented Dec 6, 2019

This fixes #425

@harvsu harvsu changed the title Workaround for Strict mode Untagged socket issue Workaround for Strict mode Untagged Socket issue Dec 6, 2019
} else {
this.configurationClient = new ConfigurationClient(applicationContext,
TelemetryUtils.createFullUserAgent(userAgent, applicationContext), sAccessToken.get(),
new OkHttpClient().newBuilder().build());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

builder is unused

// Strict mode work around : https://github.com/square/okhttp/issues/3537
this.configurationClient = new ConfigurationClient(applicationContext,
TelemetryUtils.createFullUserAgent(userAgent, applicationContext), sAccessToken.get(),
new OkHttpClient().newBuilder()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could consider moving this code to TelemetryUtils

Copy link
Contributor

@nkukday nkukday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments/suggestions, overall 🚀

Add custom socket factory and set TrafficStats.setThreadStatsTag(1000) for configuration client(okhttpClient).
@harvsu harvsu force-pushed the fix-strict-mode-socket-error branch from 9da6387 to 02c088a Compare December 16, 2019 23:41
@harvsu harvsu self-assigned this Dec 16, 2019
@harvsu harvsu merged commit 40b8f44 into master Dec 16, 2019
@codecov
Copy link

codecov bot commented Dec 16, 2019

Codecov Report

Merging #443 into master will decrease coverage by 0.19%.
The diff coverage is 33.33%.

@@             Coverage Diff             @@
##             master     #443     +/-   ##
===========================================
- Coverage     68.65%   68.46%   -0.2%     
- Complexity      394      395      +1     
===========================================
  Files            69       69             
  Lines          2144     2156     +12     
  Branches        171      171             
===========================================
+ Hits           1472     1476      +4     
- Misses          575      583      +8     
  Partials         97       97

harvsu pushed a commit that referenced this pull request Mar 12, 2020
harvsu pushed a commit that referenced this pull request Mar 12, 2020
Add custom socket factory and set TrafficStats.setThreadStatsTag(1000) for configuration client(okhttpClient).

(cherry picked from commit 40b8f44)
harvsu pushed a commit that referenced this pull request Mar 16, 2020
harvsu pushed a commit that referenced this pull request Mar 16, 2020
Set version in gradle.properties .
Replace master with long-term-support in config.yml .
harvsu pushed a commit that referenced this pull request Mar 17, 2020
harvsu added a commit that referenced this pull request Mar 17, 2020
Add custom socket factory and set TrafficStats.setThreadStatsTag(1000) for configuration client(okhttpClient).
harvsu added a commit that referenced this pull request Mar 17, 2020
harvsu added a commit that referenced this pull request Mar 17, 2020
Add custom socket factory and set TrafficStats.setThreadStatsTag(1000) for configuration client(okhttpClient).
harvsu added a commit that referenced this pull request Mar 18, 2020
* Update Changelog.md for release Core 1.4.0 / Telemetry 4.7.0(#440)

* Update Gradle Versions: (#444)

Gradle Version : 5.6.4
Android Gradle Plugin Version : 3.5.3

* Update Node version to >=10 in package.json (#445)

Update version to 4.7.1 in package.json

* Workaround for Strict mode socket issue: (#443)

Add custom socket factory and set TrafficStats.setThreadStatsTag(1000) for configuration client(okhttpClient).

* Fix Turnstile Obfuscation (#457)

* Fix obfuscation:

Prevent obfuscation of Event classes to keep properties in JSON schema unaltered.
Throw Assertion Error in Test App in case of POST failure for an event.
Set minifyEnabled true in build.gradle for debug build to make the test
app behave close to production app.
Add button on test app's main screen, which sends turnstile event on click.
Add @SerializedName annotation to Turnstile and Crash Event properties
to keep them consistent with other events.
Fix Location Schema test to ignore the properties(speed, course, floor,
speedAccuracy, courseAccuracy, and verticalAccuracy) that are
added in the backend but not incorporated into the SDK yet!

* Update Config.yml to indicate long-term-support as pseudo master branch.
Append -lts to name of the binary while publishing the binary size.
Update Version in gradle.properties and package.json.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants