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

Commit 1e70c0b9 authored by Slawomir Rosek's avatar Slawomir Rosek
Browse files

Disable transcoding by default if no HEVC support



This patch by default disables transcoding if HEVC decoder is not
supported. It may still be enabled/disabled via persistet properties
and/or device_config settings.

Bug: 270324498
Bug: 270320827
Test: run cts -m CtsMediaProviderTranscodeTests
Test: run cts -m CtsMediaTranscodingTestCases
Change-Id: I63ac7f4dd5103bea3f67a491a3fe030bafce075c
Signed-off-by: default avatarSlawomir Rosek <srosek@google.com>
parent f38b2252
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@ import android.content.pm.ProviderInfo;
import android.content.pm.UserInfo;
import android.content.res.ObbInfo;
import android.database.ContentObserver;
import android.media.MediaCodecList;
import android.media.MediaCodecInfo;
import android.media.MediaFormat;
import android.net.Uri;
import android.os.BatteryManager;
import android.os.Binder;
@@ -1006,10 +1009,27 @@ class StorageManagerService extends IStorageManager.Stub
        }
    }

    private boolean isHevcDecoderSupported() {
        MediaCodecList codecList = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
        MediaCodecInfo[] codecInfos = codecList.getCodecInfos();
        for (MediaCodecInfo codecInfo : codecInfos) {
            if (codecInfo.isEncoder()) {
                continue;
            }
            String[] supportedTypes = codecInfo.getSupportedTypes();
            for (String type : supportedTypes) {
                if (type.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_HEVC)) {
                    return true;
                }
            }
        }
        return false;
    }

    private void configureTranscoding() {
        // See MediaProvider TranscodeHelper#getBooleanProperty for more information
        boolean transcodeEnabled = false;
        boolean defaultValue = true;
        boolean defaultValue = isHevcDecoderSupported() ? true : false;

        if (SystemProperties.getBoolean("persist.sys.fuse.transcode_user_control", false)) {
            transcodeEnabled = SystemProperties.getBoolean("persist.sys.fuse.transcode_enabled",