Skip to content

Commit

Permalink
Merge pull request #2353 from DataDog/jmoskovich/cherrypick-privacy-fix
Browse files Browse the repository at this point in the history
Fix checkable mapper privacy issue
  • Loading branch information
jonathanmos authored Oct 28, 2024
2 parents e93856f + 5ebd247 commit b68f6b3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
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

0 comments on commit b68f6b3

Please sign in to comment.