Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [18.0.3]
### Changed
- Modified how we pass the content id of purchases in custom events
- Moved referrerClient.installReferrer to its own thread to avoid blocking the main thread with slow binder calls [Issue: com.android.installreferrer is called in the main thread which leads to ANR](https://github.com/facebook/facebook-android-sdk/issues/1039)
### Added
- Added permissions ACCESS_ADSERVICES_TOPICS to access Google Privacy Sandbox AdServices API. If you need to disable any of the permissions, please include the tools:node="remove" node marker for the particular permissions.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,32 @@ object InstallReferrerUtil {
override fun onInstallReferrerSetupFinished(responseCode: Int) {
when (responseCode) {
InstallReferrerResponse.OK -> {
val response: ReferrerDetails =
// referrerClient.installReferrer results in a binder call,
// which should not be made on the main thread
Thread {
val response: ReferrerDetails? =
try {
referrerClient.installReferrer
} catch (e: RemoteException) {
return
null
} finally {
referrerClient.endConnection()
}
val referrerUrl = response.installReferrer
if (referrerUrl != null &&
(referrerUrl.contains("fb") || referrerUrl.contains("facebook"))) {
callback.onReceiveReferrerUrl(referrerUrl)
}
// Even if we are not interested in the url, there is no reason to update again
updateReferrer()
if (response == null) return@Thread
val referrerUrl = response.installReferrer
if (referrerUrl != null &&
(referrerUrl.contains("fb") || referrerUrl.contains("facebook"))
) {
callback.onReceiveReferrerUrl(referrerUrl)
}
// Even if we are not interested in the url, there is no reason to update again
updateReferrer()
}.start()
}
InstallReferrerResponse.FEATURE_NOT_SUPPORTED ->
updateReferrer() // No point retrying if feature not supported
InstallReferrerResponse.SERVICE_UNAVAILABLE -> {}
}
try {
referrerClient.endConnection()
} catch (e: Exception) {
// Silent endConnection errors for unit test and else
}
}

override fun onInstallReferrerServiceDisconnected() = Unit
Expand Down