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

send fraudFailureReasons array #373

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion example/src/main/java/io/radar/example/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class MainActivity : AppCompatActivity() {
}

Radar.trackVerified(false) { status, token ->
Log.v("example", "TrackVerified: status = $status; token = ${token?.toJson()}")
Log.v("example", "Track verified: status = $status; token = ${token?.toJson()}")
}

// In the Radar dashboard settings (https://radar.com/dashboard/settings), add this to
Expand Down
2 changes: 1 addition & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apply plugin: "org.jetbrains.dokka"
apply plugin: 'io.radar.mvnpublish'

ext {
radarVersion = '3.13.2'
radarVersion = '3.13.3'
}

String buildNumber = ".${System.currentTimeMillis()}"
Expand Down
11 changes: 10 additions & 1 deletion sdk/src/main/java/io/radar/sdk/RadarApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,13 @@ internal class RadarApiClient(
} else {
params.putOpt("xPlatformType", "Native")
}
val fraudFailureReasons = mutableListOf<String>()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
val mocked = location.isFromMockProvider
params.putOpt("mocked", mocked)
if (mocked) {
fraudFailureReasons.add("fraud_mocked_from_mock_provider")
}
}
if (tripOptions != null) {
val tripOptionsObj = JSONObject()
Expand Down Expand Up @@ -338,10 +342,15 @@ internal class RadarApiClient(
if (verified) {
params.putOpt("integrityToken", integrityToken)
params.putOpt("integrityException", integrityException)
params.putOpt("sharing", RadarUtils.isScreenSharing(context))
val sharingFailureReasons = RadarUtils.isScreenSharing(context)
if (sharingFailureReasons.isNotEmpty()) {
params.putOpt("sharing", true)
fraudFailureReasons.addAll(sharingFailureReasons)
}
params.putOpt("encrypted", encrypted)
}
params.putOpt("appId", context.packageName)
params.putOpt("fraudFailureReasons", fraudFailureReasons)
} catch (e: JSONException) {
callback?.onComplete(RadarStatus.ERROR_BAD_REQUEST)

Expand Down
15 changes: 12 additions & 3 deletions sdk/src/main/java/io/radar/sdk/RadarUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,25 @@ internal object RadarUtils {
|| Build.PRODUCT.contains("simulator");
}

internal fun isScreenSharing(context: Context): Boolean {
internal fun isScreenSharing(context: Context): List<String> {
val sharingFailureReasons = mutableListOf<String>()

if (Build.VERSION.SDK_INT < 17) {
return false
return sharingFailureReasons
}

val displayManager = DisplayManagerCompat.getInstance(context)
val multipleDisplays = displayManager.displays.size > 1
if (multipleDisplays) {
sharingFailureReasons.add("fraud_sharing_multiple_displays")
}

val sharing = RadarSettings.getSharing(context)
if (sharing) {
sharingFailureReasons.add("fraud_sharing_virtual_input_device")
}

return multipleDisplays || sharing
return sharingFailureReasons
}

internal fun isoStringToDate(str: String?): Date? {
Expand Down