From 52b80a4821f12c2fd66df9adf3f381558ff32902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=A0ng=20Gia=20B=E1=BA=A3o?= <70064328+YT-Advanced@users.noreply.github.com> Date: Sun, 8 Dec 2024 19:27:51 +0700 Subject: [PATCH 1/3] refactor(YouTube - Spoof Streaming Data): Remove `Force AVC` settings --- .../patches/misc/client/AppClient.java | 18 ++----- .../misc/client/DeviceHardwareSupport.java | 54 ------------------- .../extension/youtube/settings/Settings.java | 2 - .../video/playback/VideoPlaybackPatch.kt | 2 +- .../youtube/settings/host/values/strings.xml | 6 --- .../youtube/settings/xml/revanced_prefs.xml | 1 - 6 files changed, 5 insertions(+), 78 deletions(-) delete mode 100644 extensions/shared/src/main/java/app/revanced/extension/youtube/patches/misc/client/DeviceHardwareSupport.java diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/misc/client/AppClient.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/misc/client/AppClient.java index 79f72f997a..6c84464f18 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/misc/client/AppClient.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/misc/client/AppClient.java @@ -24,7 +24,6 @@ public class AppClient { private static final String CLIENT_VERSION_IOS = "19.47.7"; private static final String DEVICE_MAKE_IOS = "Apple"; /** - * The device machine id for the iPhone XS Max (iPhone11,4), used to get 60fps. * The device machine id for the iPhone 16 Pro Max (iPhone17,2), used to get HDR with AV1 hardware decoding. * *
@@ -32,20 +31,11 @@ public class AppClient { * information. *
*/ - private static final String DEVICE_MODEL_IOS = DeviceHardwareSupport.allowAV1() - ? "iPhone17,2" - : "iPhone11,4"; + private static final String DEVICE_MODEL_IOS = "iPhone17,2" private static final String OS_NAME_IOS = "iOS"; - /** - * The minimum supported OS version for the iOS YouTube client is iOS 14.0. - * Using an invalid OS version will use the AVC codec. - */ - private static final String OS_VERSION_IOS = DeviceHardwareSupport.allowVP9() - ? "18.1.1.22B91" - : "13.7.17H35"; - private static final String USER_AGENT_VERSION_IOS = DeviceHardwareSupport.allowVP9() - ? "18_1_1" - : "13_7"; + private static final String OS_VERSION_IOS = "18.1.1.22B91" + private static final String USER_AGENT_VERSION_IOS = "18_1_1" + private static final String USER_AGENT_IOS = "com.google.ios.youtube/" + CLIENT_VERSION_IOS + "(" + diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/misc/client/DeviceHardwareSupport.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/misc/client/DeviceHardwareSupport.java deleted file mode 100644 index 91ffd5aae5..0000000000 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/misc/client/DeviceHardwareSupport.java +++ /dev/null @@ -1,54 +0,0 @@ -package app.revanced.extension.youtube.patches.misc.client; - -import static app.revanced.extension.shared.utils.Utils.isSDKAbove; - -import android.media.MediaCodecInfo; -import android.media.MediaCodecList; - -import app.revanced.extension.shared.utils.Logger; -import app.revanced.extension.youtube.settings.Settings; - -public class DeviceHardwareSupport { - private static final boolean DEVICE_HAS_HARDWARE_DECODING_VP9; - private static final boolean DEVICE_HAS_HARDWARE_DECODING_AV1; - - static { - boolean vp9found = false; - boolean av1found = false; - MediaCodecList codecList = new MediaCodecList(MediaCodecList.ALL_CODECS); - final boolean deviceIsAndroidTenOrLater = isSDKAbove(29); - - for (MediaCodecInfo codecInfo : codecList.getCodecInfos()) { - final boolean isHardwareAccelerated = deviceIsAndroidTenOrLater - ? codecInfo.isHardwareAccelerated() - : !codecInfo.getName().startsWith("OMX.google"); // Software decoder. - if (isHardwareAccelerated && !codecInfo.isEncoder()) { - for (String type : codecInfo.getSupportedTypes()) { - if (type.equalsIgnoreCase("video/x-vnd.on2.vp9")) { - vp9found = true; - } else if (type.equalsIgnoreCase("video/av01")) { - av1found = true; - } - } - } - } - - DEVICE_HAS_HARDWARE_DECODING_VP9 = vp9found; - DEVICE_HAS_HARDWARE_DECODING_AV1 = av1found; - - Logger.printDebug(() -> DEVICE_HAS_HARDWARE_DECODING_AV1 - ? "Device supports AV1 hardware decoding\n" - : "Device does not support AV1 hardware decoding\n" - + (DEVICE_HAS_HARDWARE_DECODING_VP9 - ? "Device supports VP9 hardware decoding" - : "Device does not support VP9 hardware decoding")); - } - - public static boolean allowVP9() { - return DEVICE_HAS_HARDWARE_DECODING_VP9 && !Settings.SPOOF_STREAMING_DATA_IOS_FORCE_AVC.get(); - } - - public static boolean allowAV1() { - return allowVP9() && DEVICE_HAS_HARDWARE_DECODING_AV1; - } -} diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/Settings.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/Settings.java index bdb78aaa51..5cd1d3d6a4 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/Settings.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/Settings.java @@ -545,8 +545,6 @@ public class Settings extends BaseSettings { // PreferenceScreen: Miscellaneous - Spoof streaming data // The order of the settings should not be changed otherwise the app may crash public static final BooleanSetting SPOOF_STREAMING_DATA = new BooleanSetting("revanced_spoof_streaming_data", TRUE, true, "revanced_spoof_streaming_data_user_dialog_message"); - public static final BooleanSetting SPOOF_STREAMING_DATA_IOS_FORCE_AVC = new BooleanSetting("revanced_spoof_streaming_data_ios_force_avc", FALSE, true, - "revanced_spoof_streaming_data_ios_force_avc_user_dialog_message", new SpoofStreamingDataPatch.iOSAvailability()); public static final BooleanSetting SPOOF_STREAMING_DATA_IOS_SKIP_LIVESTREAM_PLAYBACK = new BooleanSetting("revanced_spoof_streaming_data_ios_skip_livestream_playback", TRUE, true, new SpoofStreamingDataPatch.iOSAvailability()); public static final EnumSetting