diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt index 1f7ead84..4228b773 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt @@ -1,19 +1,14 @@ package app.revanced.patches.reddit.customclients -import android.os.Environment import app.revanced.extensions.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.PatchException -import app.revanced.patcher.patch.options.PatchOptionException import app.revanced.patcher.patch.options.types.StringPatchOption.Companion.stringPatchOption -import java.io.File -import java.util.* abstract class AbstractSpoofClientPatch( - private val redirectUri: String, + redirectUri: String, private val clientIdFingerprints: List, private val userAgentFingerprints: List? = null, private val miscellaneousFingerprints: List? = null @@ -34,59 +29,6 @@ abstract class AbstractSpoofClientPatch( ) override fun execute(context: BytecodeContext) { - val requiredOptions = options.values.filter { it.required } - - val isAndroidButRequiredOptionsUnset = try { - Class.forName("android.os.Environment") - - requiredOptions.any { it.value == null } - } catch (_: ClassNotFoundException) { - false - } - - if (isAndroidButRequiredOptionsUnset) { - val properties = Properties() - - val propertiesFile = File( - Environment.getExternalStorageDirectory(), - "revanced_client_spoof_${redirectUri.hashCode()}.properties" - ) - if (propertiesFile.exists()) { - properties.load(propertiesFile.inputStream()) - - // Set options from properties file. - properties.forEach { (name, value) -> - try { - options[name.toString()] = value.toString().trim() - } catch (_: PatchOptionException.PatchOptionNotFoundException) { - // Ignore unknown options. - } - } - } else { - options.keys.forEach { properties.setProperty(it, "") } - - properties.store( - propertiesFile.outputStream(), - "Options for the ReVanced \"Client Spoof\" patch. Required options: " + - requiredOptions.joinToString { it.key } - ) - } - - requiredOptions.filter { it.value == null }.let { requiredUnsetOptions -> - if (requiredUnsetOptions.isEmpty()) return@let - - val error = """ - In order to use this patch, you need to provide the following options: - ${requiredUnsetOptions.joinToString("\n") { "${it.key}: ${it.description}" }} - - A properties file has been created at ${propertiesFile.absolutePath}. - Please fill in the required options before using this patch. - """.trimIndent() - - throw PatchException(error) - } - } - fun List?.executePatch( patch: List.(BytecodeContext) -> Unit ) = this?.map { it.result ?: throw it.exception }?.patch(context)