revert: fix custom camera frame rate

This commit is contained in:
rhunk 2024-05-03 19:06:02 +02:00
parent 3718fa3e2f
commit fcf82de988

View File

@ -18,7 +18,6 @@ import me.rhunk.snapenhance.core.util.hook.hook
import me.rhunk.snapenhance.core.util.ktx.setObjectField
import java.io.ByteArrayOutputStream
import java.nio.ByteBuffer
import kotlin.math.abs
class CameraTweaks : Feature("Camera Tweaks", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) {
@ -92,16 +91,7 @@ class CameraTweaks : Feature("Camera Tweaks", loadParams = FeatureLoadParams.ACT
arrayOf(CameraCharacteristics.LENS_FACING)
) == CameraCharacteristics.LENS_FACING_FRONT
val customFrameRate = (if (isFrontCamera) config.frontCustomFrameRate.getNullable() else config.backCustomFrameRate.getNullable())?.toIntOrNull() ?: return@hook
val fpsRanges = param.getResult() as? Array<*> ?: return@hook
param.setResult(arrayOf(Range(customFrameRate, customFrameRate)))
if (customFrameRate <= 30) return@hook
val closestMaxFps = fpsRanges.mapNotNull {
(it as? Range<*>)?.upper?.toString()?.toIntOrNull()
}.minByOrNull { abs(it - customFrameRate) } ?: return@hook
param.setResult(arrayOf(Range(closestMaxFps, closestMaxFps)))
}
}