Skip to content

Commit

Permalink
chore: lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
inotia00 committed Oct 12, 2024
1 parent 4bc6303 commit d20582b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ object MiniplayerPatch : BaseBytecodePatch(

// Modern mini player is only present and functional in 19.15+.
// Resource is not present in older versions. Using it to determine, if patching an old version.
val isPatchingOldVersion = !SettingsPatch.upward1912
val isPatchingOldVersion = !SettingsPatch.upward1915

// From 19.12 to 19.16 using mixed up drawables for tablet modern.
// From 19.15 to 19.16 using mixed up drawables for tablet modern.
val shouldFixMixedUpDrawables = YtOutlineXWhite > 0 && YtOutlinePictureInPictureWhite > 0

// region Enable tablet miniplayer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ object SettingsPatch : BaseResourcePatch(
internal var upward1842 = false
internal var upward1849 = false
internal var upward1902 = false
internal var upward1912 = false
internal var upward1915 = false
internal var upward1923 = false
internal var upward1925 = false
internal var upward1928 = false
Expand Down Expand Up @@ -288,7 +288,7 @@ object SettingsPatch : BaseResourcePatch(
upward1842 = 234302000 <= playServicesVersion
upward1849 = 235000000 <= playServicesVersion
upward1902 = 240204000 < playServicesVersion
upward1912 = 241302000 <= playServicesVersion
upward1915 = 241602000 <= playServicesVersion
upward1923 = 242402000 <= playServicesVersion
upward1925 = 242599000 <= playServicesVersion
upward1928 = 242905000 <= playServicesVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.patches.youtube.video.playerresponse.fingerprint.PlayerParameterBuilderFingerprint.ENDS_WITH_PARAMETER_LIST
import app.revanced.patches.youtube.video.playerresponse.fingerprint.PlayerParameterBuilderFingerprint.STARTS_WITH_PARAMETER_LIST
import app.revanced.patches.youtube.video.playerresponse.fingerprint.PlayerParameterBuilderFingerprint.parametersEqual
import app.revanced.util.parametersEqual
import com.android.tools.smali.dexlib2.AccessFlags

internal object PlayerParameterBuilderFingerprint : MethodFingerprint(
Expand Down Expand Up @@ -48,21 +48,21 @@ internal object PlayerParameterBuilderFingerprint : MethodFingerprint(
}

val startsWithMethodParameterList = parameterTypes.slice(0..5)
val endsWithMethodParameterList = parameterTypes.slice(parameterSize - 7..<parameterSize)
val endsWithMethodParameterList = parameterTypes.slice(parameterSize - 7..< parameterSize)

parametersEqual(STARTS_WITH_PARAMETER_LIST, startsWithMethodParameterList)
&& parametersEqual(ENDS_WITH_PARAMETER_LIST, endsWithMethodParameterList)
parametersEqual(STARTS_WITH_PARAMETER_LIST, startsWithMethodParameterList) &&
parametersEqual(ENDS_WITH_PARAMETER_LIST, endsWithMethodParameterList)
}
) {
val STARTS_WITH_PARAMETER_LIST = listOf(
private val STARTS_WITH_PARAMETER_LIST = listOf(
"Ljava/lang/String;", // VideoId.
"[B",
"Ljava/lang/String;", // Player parameters proto buffer.
"Ljava/lang/String;", // PlaylistId.
"I",
"I"
)
val ENDS_WITH_PARAMETER_LIST = listOf(
private val ENDS_WITH_PARAMETER_LIST = listOf(
"Ljava/util/Set;",
"Ljava/lang/String;",
"Ljava/lang/String;",
Expand All @@ -71,16 +71,4 @@ internal object PlayerParameterBuilderFingerprint : MethodFingerprint(
"Z",
"Z"
)

fun parametersEqual(
parameters1: Iterable<CharSequence>,
parameters2: Iterable<CharSequence>
): Boolean {
if (parameters1.count() != parameters2.count()) return false
val iterator1 = parameters1.iterator()
parameters2.forEach {
if (!it.startsWith(iterator1.next())) return false
}
return true
}
}
12 changes: 12 additions & 0 deletions src/main/kotlin/app/revanced/util/BytecodeUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ fun MethodFingerprint.resultOrThrow() = result ?: throw exception

fun MultiMethodFingerprint.resultOrThrow() = result.ifEmpty { throw exception }

fun parametersEqual(
parameters1: Iterable<CharSequence>,
parameters2: Iterable<CharSequence>
): Boolean {
if (parameters1.count() != parameters2.count()) return false
val iterator1 = parameters1.iterator()
parameters2.forEach {
if (!it.startsWith(iterator1.next())) return false
}
return true
}

/**
* The [PatchException] of failing to resolve a [MethodFingerprint].
*
Expand Down

0 comments on commit d20582b

Please sign in to comment.