android: limit PiP view size to adapt to Android limitations (#5468)

This commit is contained in:
Stanislav Dmitrenko
2025-01-03 07:53:10 +00:00
committed by GitHub
parent 23b20ac743
commit 4813ab526d
@@ -99,7 +99,8 @@ class CallActivity: ComponentActivity(), ServiceConnection {
fun setPipParams(video: Boolean, sourceRectHint: Rect? = null, viewRatio: Rational? = null) {
// By manually specifying source rect we exclude empty background while toggling PiP
val builder = PictureInPictureParams.Builder()
.setAspectRatio(viewRatio)
// that's limitation of Android. Otherwise, may crash on devices like Z Fold 3
.setAspectRatio(viewRatio?.coerceIn(Rational(100, 239)..Rational(239, 100)))
.setSourceRectHint(sourceRectHint)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
builder.setAutoEnterEnabled(video)