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

Fix checkable mapper privacy issue #2343

Merged
merged 1 commit into from
Oct 24, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ internal abstract class CheckableTextViewMapper<T>(
)
mappingContext.imageWireframeHelper.createImageWireframe(
view = view,
imagePrivacy = mappingContext.imagePrivacy,
imagePrivacy = mapInputPrivacyToImagePrivacy(mappingContext.textAndInputPrivacy),
currentWireframeIndex = 0,
x = checkBoxBounds.x,
y = checkBoxBounds.y,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.view.View
import android.widget.Checkable
import androidx.annotation.UiThread
import com.datadog.android.api.InternalLogger
import com.datadog.android.sessionreplay.ImagePrivacy
import com.datadog.android.sessionreplay.TextAndInputPrivacy
import com.datadog.android.sessionreplay.model.MobileSegment
import com.datadog.android.sessionreplay.recorder.MappingContext
Expand Down Expand Up @@ -52,6 +53,14 @@ internal abstract class CheckableWireframeMapper<T>(
return mainWireframes
}

protected fun mapInputPrivacyToImagePrivacy(inputPrivacy: TextAndInputPrivacy): ImagePrivacy {
return when (inputPrivacy) {
TextAndInputPrivacy.MASK_SENSITIVE_INPUTS -> ImagePrivacy.MASK_NONE
TextAndInputPrivacy.MASK_ALL_INPUTS,
TextAndInputPrivacy.MASK_ALL -> ImagePrivacy.MASK_ALL
}
}

@UiThread
abstract fun resolveMainWireframes(
view: T,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ internal open class SwitchCompatMapper(
}?.let { drawable ->
mappingContext.imageWireframeHelper.createImageWireframe(
view = view,
imagePrivacy = mappingContext.imagePrivacy,
imagePrivacy = mapInputPrivacyToImagePrivacy(mappingContext.textAndInputPrivacy),
currentWireframeIndex = prevIndex + 1,
x = trackBounds.x.densityNormalized(mappingContext.systemInformation.screenDensity).toLong(),
y = trackBounds.y.densityNormalized(mappingContext.systemInformation.screenDensity).toLong(),
Expand Down Expand Up @@ -111,7 +111,7 @@ internal open class SwitchCompatMapper(
thumbBounds?.let { thumbBounds ->
mappingContext.imageWireframeHelper.createImageWireframe(
view = view,
imagePrivacy = mappingContext.imagePrivacy,
imagePrivacy = mapInputPrivacyToImagePrivacy(mappingContext.textAndInputPrivacy),
currentWireframeIndex = prevIndex + 1,
x = thumbBounds.x.densityNormalized(mappingContext.systemInformation.screenDensity).toLong(),
y = thumbBounds.y.densityNormalized(mappingContext.systemInformation.screenDensity).toLong(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ internal abstract class BaseCheckableTextViewMapperTest<T> :
// Then
verify(fakeMappingContext.imageWireframeHelper).createImageWireframe(
view = eq(mockCheckableTextView),
imagePrivacy = eq(ImagePrivacy.MASK_LARGE_ONLY),
imagePrivacy = eq(ImagePrivacy.MASK_NONE),
currentWireframeIndex = anyInt(),
x = eq(expectedX),
y = eq(expectedY),
Expand Down Expand Up @@ -261,7 +261,7 @@ internal abstract class BaseCheckableTextViewMapperTest<T> :
// Then
verify(fakeMappingContext.imageWireframeHelper).createImageWireframe(
view = eq(mockCheckableTextView),
imagePrivacy = eq(ImagePrivacy.MASK_LARGE_ONLY),
imagePrivacy = eq(ImagePrivacy.MASK_NONE),
currentWireframeIndex = anyInt(),
x = eq(expectedX),
y = eq(expectedY),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ internal class SwitchCompatMapperTest : BaseSwitchCompatMapperTest() {

verify(fakeMappingContext.imageWireframeHelper, times(2)).createImageWireframe(
view = eq(mockSwitch),
imagePrivacy = eq(ImagePrivacy.MASK_LARGE_ONLY),
imagePrivacy = eq(ImagePrivacy.MASK_NONE),
currentWireframeIndex = ArgumentMatchers.anyInt(),
x = xCaptor.capture(),
y = yCaptor.capture(),
Expand Down