Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a36c8a4 authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge remote-tracking branch 'origin/lineage-23.0' into a16

parents ef2220c0 2dc97cf3
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@ import android.app.Activity
import android.app.PendingIntent
import android.content.Intent
import android.hardware.display.DisplayManager
import android.media.MediaCodecInfo
import android.media.MediaCodecList
import android.media.MediaFormat
import android.os.Build
import android.os.Bundle
import android.os.Handler
@@ -186,6 +189,12 @@ class ScreenRecordPermissionViewBinder(
            audioSwitch.isChecked = true
        }

        // Disable HEVC when hardware accelerated codec is not available
        if (!hasHevcHwEncoder()) {
            Prefs.putInt(userContextProvider.userContext, PREF_HEVC, 0)
            containerView.requireViewById<View>(R.id.show_hevc).visibility = View.GONE
        }

        // disable redundant Touch & Hold accessibility action for Switch Access
        options.accessibilityDelegate =
            object : View.AccessibilityDelegate() {
@@ -260,6 +269,24 @@ class ScreenRecordPermissionViewBinder(
                INTERVAL_MS, startIntent, stopIntent)
    }

    private fun hasHevcHwEncoder(): Boolean {
        val mediaCodecList = MediaCodecList(MediaCodecList.REGULAR_CODECS)

        for (codecInfo in mediaCodecList.getCodecInfos()) {
            if (!codecInfo.isEncoder() || !codecInfo.isHardwareAccelerated()) {
                continue
            }

            for (type in codecInfo.getSupportedTypes()) {
                if (type.equals(MediaFormat.MIMETYPE_VIDEO_HEVC, ignoreCase = true)) {
                    return true
                }
            }
        }

        return false
    }

    private fun savePrefs() {
        val userContext = userContextProvider.userContext
        Prefs.putInt(userContext, PREF_TAPS, if (tapsSwitch.isChecked) 1 else 0)