diff --git a/patches/api/patches.api b/patches/api/patches.api index 60eb96c..eaf1ba3 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -1,137 +1,3 @@ -public final class app/revanced/patches/all/misc/activity/exportall/ExportAllActivitiesPatchKt { - public static final fun getExportAllActivitiesPatch ()Lapp/revanced/patcher/patch/ResourcePatch; -} - -public final class app/revanced/patches/all/misc/build/BaseSpoofBuildInfoPatchKt { - public static final fun baseSpoofBuildInfoPatch (Lkotlin/jvm/functions/Function0;)Lapp/revanced/patcher/patch/BytecodePatch; -} - -public final class app/revanced/patches/all/misc/build/BuildInfo { - public fun ()V - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getBoard ()Ljava/lang/String; - public final fun getBootloader ()Ljava/lang/String; - public final fun getBrand ()Ljava/lang/String; - public final fun getCpuAbi ()Ljava/lang/String; - public final fun getCpuAbi2 ()Ljava/lang/String; - public final fun getDevice ()Ljava/lang/String; - public final fun getDisplay ()Ljava/lang/String; - public final fun getFingerprint ()Ljava/lang/String; - public final fun getHardware ()Ljava/lang/String; - public final fun getHost ()Ljava/lang/String; - public final fun getId ()Ljava/lang/String; - public final fun getManufacturer ()Ljava/lang/String; - public final fun getModel ()Ljava/lang/String; - public final fun getOdmSku ()Ljava/lang/String; - public final fun getProduct ()Ljava/lang/String; - public final fun getRadio ()Ljava/lang/String; - public final fun getSerial ()Ljava/lang/String; - public final fun getSku ()Ljava/lang/String; - public final fun getSocManufacturer ()Ljava/lang/String; - public final fun getSocModel ()Ljava/lang/String; - public final fun getTags ()Ljava/lang/String; - public final fun getTime ()Ljava/lang/Long; - public final fun getType ()Ljava/lang/String; - public final fun getUser ()Ljava/lang/String; -} - -public final class app/revanced/patches/all/misc/build/SpoofBuildInfoPatchKt { - public static final fun getSpoofBuildInfoPatch ()Lapp/revanced/patcher/patch/BytecodePatch; -} - -public final class app/revanced/patches/all/misc/connectivity/location/hide/HideMockLocationPatchKt { - public static final fun getHideMockLocationPatch ()Lapp/revanced/patcher/patch/BytecodePatch; -} - -public final class app/revanced/patches/all/misc/connectivity/telephony/sim/spoof/SpoofSimCountryPatchKt { - public static final fun getSpoofSimCountryPatch ()Lapp/revanced/patcher/patch/BytecodePatch; -} - -public final class app/revanced/patches/all/misc/connectivity/wifi/spoof/SpoofWifiPatchKt { - public static final fun getSpoofWifiPatch ()Lapp/revanced/patcher/patch/BytecodePatch; -} - -public final class app/revanced/patches/all/misc/debugging/EnableAndroidDebuggingPatchKt { - public static final fun getEnableAndroidDebuggingPatch ()Lapp/revanced/patcher/patch/ResourcePatch; -} - -public final class app/revanced/patches/all/misc/directory/ChangeDataDirectoryLocationPatchKt { - public static final fun getChangeDataDirectoryLocationPatch ()Lapp/revanced/patcher/patch/BytecodePatch; -} - -public final class app/revanced/patches/all/misc/directory/documentsprovider/ExportInternalDataDocumentsProviderPatchKt { - public static final fun getExportInternalDataDocumentsProviderPatch ()Lapp/revanced/patcher/patch/ResourcePatch; -} - -public final class app/revanced/patches/all/misc/hex/HexPatchKt { - public static final fun getHexPatch ()Lapp/revanced/patcher/patch/RawResourcePatch; -} - -public final class app/revanced/patches/all/misc/interaction/gestures/PredictiveBackGesturePatchKt { - public static final fun getPredictiveBackGesturePatch ()Lapp/revanced/patcher/patch/ResourcePatch; -} - -public final class app/revanced/patches/all/misc/network/OverrideCertificatePinningPatchKt { - public static final fun getOverrideCertificatePinningPatch ()Lapp/revanced/patcher/patch/ResourcePatch; -} - -public final class app/revanced/patches/all/misc/packagename/ChangePackageNamePatchKt { - public static field packageNameOption Lapp/revanced/patcher/patch/Option; - public static final fun getChangePackageNamePatch ()Lapp/revanced/patcher/patch/ResourcePatch; - public static final fun getPackageNameOption ()Lapp/revanced/patcher/patch/Option; - public static final fun setOrGetFallbackPackageName (Ljava/lang/String;)Ljava/lang/String; - public static final fun setPackageNameOption (Lapp/revanced/patcher/patch/Option;)V -} - -public final class app/revanced/patches/all/misc/resources/AddResourcesPatchKt { - public static final fun addResource (Ljava/lang/String;Lapp/revanced/util/resource/BaseResource;)Z - public static final fun addResources (Lapp/revanced/patcher/patch/Patch;Lkotlin/jvm/functions/Function1;)Z - public static final fun addResources (Ljava/lang/String;Ljava/lang/Iterable;)Z - public static final fun addResources (Ljava/lang/String;Ljava/lang/String;)V - public static final fun addResources (Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;)Z - public static final fun addResources (Ljava/lang/String;Ljava/util/List;)Z - public static synthetic fun addResources$default (Lapp/revanced/patcher/patch/Patch;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Z - public static synthetic fun addResources$default (Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;ILjava/lang/Object;)Z - public static final fun getAddResourcesPatch ()Lapp/revanced/patcher/patch/ResourcePatch; -} - -public final class app/revanced/patches/all/misc/screencapture/RemoveScreenCaptureRestrictionPatchKt { - public static final fun getRemoveScreenCaptureRestrictionPatch ()Lapp/revanced/patcher/patch/BytecodePatch; -} - -public final class app/revanced/patches/all/misc/screenshot/RemoveScreenshotRestrictionPatchKt { - public static final fun getRemoveScreenshotRestrictionPatch ()Lapp/revanced/patcher/patch/BytecodePatch; -} - -public final class app/revanced/patches/all/misc/shortcut/sharetargets/RemoveShareTargetsPatchKt { - public static final fun getRemoveShareTargetsPatch ()Lapp/revanced/patcher/patch/ResourcePatch; -} - -public final class app/revanced/patches/all/misc/targetSdk/SetTargetSdkVersion34Kt { - public static final fun getSetTargetSdkVersion34 ()Lapp/revanced/patcher/patch/ResourcePatch; -} - -public abstract interface class app/revanced/patches/all/misc/transformation/IMethodCall { - public abstract fun getDefinedClassName ()Ljava/lang/String; - public abstract fun getMethodName ()Ljava/lang/String; - public abstract fun getMethodParams ()[Ljava/lang/String; - public abstract fun getReturnType ()Ljava/lang/String; - public abstract fun replaceInvokeVirtualWithExtension (Ljava/lang/String;Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;Lcom/android/tools/smali/dexlib2/iface/instruction/formats/Instruction35c;I)V -} - -public final class app/revanced/patches/all/misc/transformation/IMethodCall$DefaultImpls { - public static fun replaceInvokeVirtualWithExtension (Lapp/revanced/patches/all/misc/transformation/IMethodCall;Ljava/lang/String;Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;Lcom/android/tools/smali/dexlib2/iface/instruction/formats/Instruction35c;I)V -} - -public final class app/revanced/patches/all/misc/transformation/TransformInstructionsPatchKt { - public static final fun transformInstructionsPatch (Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function2;)Lapp/revanced/patcher/patch/BytecodePatch; -} - -public final class app/revanced/patches/all/misc/versioncode/ChangeVersionCodePatchKt { - public static final fun getChangeVersionCodePatch ()Lapp/revanced/patcher/patch/ResourcePatch; -} - public final class app/revanced/patches/calistree/pro/UnlockProPatchKt { public static final fun getUnlockProPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } @@ -169,21 +35,6 @@ public final class app/revanced/patches/shared/misc/extension/SharedExtensionPat public static final fun sharedExtensionPatch ([Lapp/revanced/patches/shared/misc/extension/ExtensionHook;)Lapp/revanced/patcher/patch/BytecodePatch; } -public final class app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatchKt { - public static final fun getVerticalScrollPatch ()Lapp/revanced/patcher/patch/BytecodePatch; -} - -public final class app/revanced/patches/shared/misc/gms/FingerprintsKt { - public static final field GET_GMS_CORE_VENDOR_GROUP_ID_METHOD_NAME Ljava/lang/String; -} - -public final class app/revanced/patches/shared/misc/gms/GmsCoreSupportPatchKt { - public static final fun gmsCoreSupportPatch (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/Fingerprint;Ljava/util/Set;Lapp/revanced/patcher/Fingerprint;Lapp/revanced/patcher/patch/Patch;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/patch/BytecodePatch; - public static synthetic fun gmsCoreSupportPatch$default (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/Fingerprint;Ljava/util/Set;Lapp/revanced/patcher/Fingerprint;Lapp/revanced/patcher/patch/Patch;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/patch/BytecodePatch; - public static final fun gmsCoreSupportResourcePatch (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/patch/Option;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/patch/ResourcePatch; - public static synthetic fun gmsCoreSupportResourcePatch$default (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/patch/Option;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/patch/ResourcePatch; -} - public final class app/revanced/patches/shared/misc/hex/HexPatchKt { public static final fun hexPatch (Lkotlin/jvm/functions/Function0;)Lapp/revanced/patcher/patch/RawResourcePatch; } @@ -217,171 +68,6 @@ public final class app/revanced/patches/shared/misc/mapping/ResourceMappingPatch public static final fun getResourceMappings ()Ljava/util/List; } -public final class app/revanced/patches/shared/misc/settings/SettingsPatchKt { - public static final fun settingsPatch (Ljava/util/List;Ljava/util/Set;)Lapp/revanced/patcher/patch/ResourcePatch; - public static final fun settingsPatch (Lkotlin/Pair;Ljava/util/Set;)Lapp/revanced/patcher/patch/ResourcePatch; - public static synthetic fun settingsPatch$default (Ljava/util/List;Ljava/util/Set;ILjava/lang/Object;)Lapp/revanced/patcher/patch/ResourcePatch; -} - -public abstract class app/revanced/patches/shared/misc/settings/preference/BasePreference { - public static final field Companion Lapp/revanced/patches/shared/misc/settings/preference/BasePreference$Companion; - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun equals (Ljava/lang/Object;)Z - public final fun getIcon ()Ljava/lang/String; - public final fun getKey ()Ljava/lang/String; - public final fun getLayout ()Ljava/lang/String; - public final fun getSummaryKey ()Ljava/lang/String; - public final fun getTag ()Ljava/lang/String; - public final fun getTitleKey ()Ljava/lang/String; - public fun hashCode ()I - public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; -} - -public final class app/revanced/patches/shared/misc/settings/preference/BasePreference$Companion { - public final fun addSummary (Lorg/w3c/dom/Element;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/SummaryType;)V - public static synthetic fun addSummary$default (Lapp/revanced/patches/shared/misc/settings/preference/BasePreference$Companion;Lorg/w3c/dom/Element;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/SummaryType;ILjava/lang/Object;)V -} - -public abstract class app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen : java/io/Closeable { - public fun ()V - public fun (Ljava/util/Set;)V - public synthetic fun (Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun close ()V - public abstract fun commit (Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference;)V -} - -public abstract class app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$BasePreferenceCollection { - public fun ()V - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getIcon ()Ljava/lang/String; - public final fun getKey ()Ljava/lang/String; - public final fun getLayout ()Ljava/lang/String; - public final fun getPreferences ()Ljava/util/Set; - public final fun getTitleKey ()Ljava/lang/String; - public abstract fun transform ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreference; -} - -public class app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen : app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$BasePreferenceCollection { - public fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference$Sorting;)V - public synthetic fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference$Sorting;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun addPreferences ([Lapp/revanced/patches/shared/misc/settings/preference/BasePreference;)V - public final fun getCategories ()Ljava/util/Set; - public synthetic fun transform ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreference; - public fun transform ()Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference; -} - -public class app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen$Category : app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$BasePreferenceCollection { - public fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;)V - public synthetic fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun addPreferences ([Lapp/revanced/patches/shared/misc/settings/preference/BasePreference;)V - public synthetic fun transform ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreference; - public fun transform ()Lapp/revanced/patches/shared/misc/settings/preference/PreferenceCategory; -} - -public final class app/revanced/patches/shared/misc/settings/preference/InputType : java/lang/Enum { - public static final field NUMBER Lapp/revanced/patches/shared/misc/settings/preference/InputType; - public static final field NUMBER_DECIMAL Lapp/revanced/patches/shared/misc/settings/preference/InputType; - public static final field TEXT Lapp/revanced/patches/shared/misc/settings/preference/InputType; - public static final field TEXT_CAP_CHARACTERS Lapp/revanced/patches/shared/misc/settings/preference/InputType; - public static final field TEXT_MULTI_LINE Lapp/revanced/patches/shared/misc/settings/preference/InputType; - public static fun getEntries ()Lkotlin/enums/EnumEntries; - public final fun getType ()Ljava/lang/String; - public static fun valueOf (Ljava/lang/String;)Lapp/revanced/patches/shared/misc/settings/preference/InputType; - public static fun values ()[Lapp/revanced/patches/shared/misc/settings/preference/InputType; -} - -public final class app/revanced/patches/shared/misc/settings/preference/IntentPreference : app/revanced/patches/shared/misc/settings/preference/BasePreference { - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun equals (Ljava/lang/Object;)Z - public final fun getIntent ()Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent; - public fun hashCode ()I - public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; -} - -public final class app/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent { - public fun (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V - public final fun copy (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;)Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent; - public static synthetic fun copy$default (Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent; - public fun equals (Ljava/lang/Object;)Z - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class app/revanced/patches/shared/misc/settings/preference/ListPreference : app/revanced/patches/shared/misc/settings/preference/BasePreference { - public fun ()V - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/util/resource/ArrayResource;Lapp/revanced/util/resource/ArrayResource;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/util/resource/ArrayResource;Lapp/revanced/util/resource/ArrayResource;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getEntries ()Lapp/revanced/util/resource/ArrayResource; - public final fun getEntriesKey ()Ljava/lang/String; - public final fun getEntryValues ()Lapp/revanced/util/resource/ArrayResource; - public final fun getEntryValuesKey ()Ljava/lang/String; - public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; -} - -public final class app/revanced/patches/shared/misc/settings/preference/NonInteractivePreference : app/revanced/patches/shared/misc/settings/preference/BasePreference { - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getSelectable ()Z - public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; -} - -public class app/revanced/patches/shared/misc/settings/preference/PreferenceCategory : app/revanced/patches/shared/misc/settings/preference/BasePreference { - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference$Sorting;Ljava/lang/String;Ljava/util/Set;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference$Sorting;Ljava/lang/String;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getPreferences ()Ljava/util/Set; - public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; -} - -public class app/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference : app/revanced/patches/shared/misc/settings/preference/BasePreference { - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference$Sorting;Ljava/lang/String;Ljava/util/Set;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference$Sorting;Ljava/lang/String;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getPreferences ()Ljava/util/Set; - public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; -} - -public final class app/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference$Sorting : java/lang/Enum { - public static final field BY_KEY Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference$Sorting; - public static final field BY_TITLE Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference$Sorting; - public static final field UNSORTED Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference$Sorting; - public final fun appendSortType (Ljava/lang/String;)Ljava/lang/String; - public static fun getEntries ()Lkotlin/enums/EnumEntries; - public final fun getKeySuffix ()Ljava/lang/String; - public static fun valueOf (Ljava/lang/String;)Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference$Sorting; - public static fun values ()[Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference$Sorting; -} - -public final class app/revanced/patches/shared/misc/settings/preference/SummaryType : java/lang/Enum { - public static final field DEFAULT Lapp/revanced/patches/shared/misc/settings/preference/SummaryType; - public static final field OFF Lapp/revanced/patches/shared/misc/settings/preference/SummaryType; - public static final field ON Lapp/revanced/patches/shared/misc/settings/preference/SummaryType; - public static fun getEntries ()Lkotlin/enums/EnumEntries; - public final fun getType ()Ljava/lang/String; - public static fun valueOf (Ljava/lang/String;)Lapp/revanced/patches/shared/misc/settings/preference/SummaryType; - public static fun values ()[Lapp/revanced/patches/shared/misc/settings/preference/SummaryType; -} - -public final class app/revanced/patches/shared/misc/settings/preference/SwitchPreference : app/revanced/patches/shared/misc/settings/preference/BasePreference { - public fun ()V - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getSummaryOffKey ()Ljava/lang/String; - public final fun getSummaryOnKey ()Ljava/lang/String; - public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; -} - -public final class app/revanced/patches/shared/misc/settings/preference/TextPreference : app/revanced/patches/shared/misc/settings/preference/BasePreference { - public fun ()V - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/InputType;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/InputType;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getInputType ()Lapp/revanced/patches/shared/misc/settings/preference/InputType; - public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; -} - public final class app/revanced/util/BytecodeUtilsKt { public static final fun addInstructionsAtControlFlowLabel (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ILjava/lang/String;)V public static final fun containsLiteralInstruction (Lcom/android/tools/smali/dexlib2/iface/Method;D)Z diff --git a/patches/build.gradle.kts b/patches/build.gradle.kts index 402d2d8..2ec1697 100644 --- a/patches/build.gradle.kts +++ b/patches/build.gradle.kts @@ -5,9 +5,9 @@ patches { name = "Brosssh Patches" description = "Brosssh Patches" source = "git@github.com:brosssh/revanced-patches.git" - author = "Brosssh" + author = "brosssh" contact = "" - website = "" + website = "https://github.com/Brosssh" license = "GNU General Public License v3.0" } } diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/activity/exportall/ExportAllActivitiesPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/activity/exportall/ExportAllActivitiesPatch.kt deleted file mode 100644 index 30193b7..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/activity/exportall/ExportAllActivitiesPatch.kt +++ /dev/null @@ -1,37 +0,0 @@ -package app.revanced.patches.all.misc.activity.exportall - -import app.revanced.patcher.patch.resourcePatch - -@Suppress("unused") -val exportAllActivitiesPatch = resourcePatch( - name = "Export all activities", - description = "Makes all app activities exportable.", - use = false, -) { - execute { - val exportedFlag = "android:exported" - - document("AndroidManifest.xml").use { document -> - val activities = document.getElementsByTagName("activity") - - for (i in 0..activities.length) { - activities.item(i)?.apply { - val exportedAttribute = attributes.getNamedItem(exportedFlag) - - if (exportedAttribute != null) { - if (exportedAttribute.nodeValue != "true") { - exportedAttribute.nodeValue = "true" - } - } - // Reason why the attribute is added in the case it does not exist: - // https://github.com/revanced/revanced-patches/pull/1751/files#r1141481604 - else { - document.createAttribute(exportedFlag) - .apply { value = "true" } - .let(attributes::setNamedItem) - } - } - } - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/build/BaseSpoofBuildInfoPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/build/BaseSpoofBuildInfoPatch.kt deleted file mode 100644 index 434b97e..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/build/BaseSpoofBuildInfoPatch.kt +++ /dev/null @@ -1,92 +0,0 @@ -package app.revanced.patches.all.misc.build - -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.all.misc.transformation.transformInstructionsPatch -import app.revanced.util.getReference -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference - -private const val BUILD_CLASS_DESCRIPTOR = "Landroid/os/Build;" - -class BuildInfo( - // The build information supported32BitAbis, supported64BitAbis, and supportedAbis are not supported for now, - // because initializing an array in transform is a bit more complex. - val board: String? = null, - val bootloader: String? = null, - val brand: String? = null, - val cpuAbi: String? = null, - val cpuAbi2: String? = null, - val device: String? = null, - val display: String? = null, - val fingerprint: String? = null, - val hardware: String? = null, - val host: String? = null, - val id: String? = null, - val manufacturer: String? = null, - val model: String? = null, - val odmSku: String? = null, - val product: String? = null, - val radio: String? = null, - val serial: String? = null, - val sku: String? = null, - val socManufacturer: String? = null, - val socModel: String? = null, - val tags: String? = null, - val time: Long? = null, - val type: String? = null, - val user: String? = null, -) - -fun baseSpoofBuildInfoPatch(buildInfoSupplier: () -> BuildInfo) = bytecodePatch { - // Lazy, so that patch options above are initialized before they are accessed. - val replacements by lazy { - with(buildInfoSupplier()) { - buildMap { - if (board != null) put("BOARD", "const-string" to "\"$board\"") - if (bootloader != null) put("BOOTLOADER", "const-string" to "\"$bootloader\"") - if (brand != null) put("BRAND", "const-string" to "\"$brand\"") - if (cpuAbi != null) put("CPU_ABI", "const-string" to "\"$cpuAbi\"") - if (cpuAbi2 != null) put("CPU_ABI2", "const-string" to "\"$cpuAbi2\"") - if (device != null) put("DEVICE", "const-string" to "\"$device\"") - if (display != null) put("DISPLAY", "const-string" to "\"$display\"") - if (fingerprint != null) put("FINGERPRINT", "const-string" to "\"$fingerprint\"") - if (hardware != null) put("HARDWARE", "const-string" to "\"$hardware\"") - if (host != null) put("HOST", "const-string" to "\"$host\"") - if (id != null) put("ID", "const-string" to "\"$id\"") - if (manufacturer != null) put("MANUFACTURER", "const-string" to "\"$manufacturer\"") - if (model != null) put("MODEL", "const-string" to "\"$model\"") - if (odmSku != null) put("ODM_SKU", "const-string" to "\"$odmSku\"") - if (product != null) put("PRODUCT", "const-string" to "\"$product\"") - if (radio != null) put("RADIO", "const-string" to "\"$radio\"") - if (serial != null) put("SERIAL", "const-string" to "\"$serial\"") - if (sku != null) put("SKU", "const-string" to "\"$sku\"") - if (socManufacturer != null) put("SOC_MANUFACTURER", "const-string" to "\"$socManufacturer\"") - if (socModel != null) put("SOC_MODEL", "const-string" to "\"$socModel\"") - if (tags != null) put("TAGS", "const-string" to "\"$tags\"") - if (time != null) put("TIME", "const-wide" to "$time") - if (type != null) put("TYPE", "const-string" to "\"$type\"") - if (user != null) put("USER", "const-string" to "\"$user\"") - } - } - } - - dependsOn( - transformInstructionsPatch( - filterMap = filterMap@{ _, _, instruction, instructionIndex -> - val reference = instruction.getReference() ?: return@filterMap null - if (reference.definingClass != BUILD_CLASS_DESCRIPTOR) return@filterMap null - - return@filterMap replacements[reference.name]?.let { instructionIndex to it } - }, - transform = { mutableMethod, entry -> - val (index, replacement) = entry - val (opcode, operand) = replacement - val register = mutableMethod.getInstruction(index).registerA - - mutableMethod.replaceInstruction(index, "$opcode v$register, $operand") - }, - ), - ) -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/build/SpoofBuildInfoPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/build/SpoofBuildInfoPatch.kt deleted file mode 100644 index 7cfd385..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/build/SpoofBuildInfoPatch.kt +++ /dev/null @@ -1,214 +0,0 @@ -package app.revanced.patches.all.misc.build - -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patcher.patch.longOption -import app.revanced.patcher.patch.stringOption - -@Suppress("unused") -val spoofBuildInfoPatch = bytecodePatch( - name = "Spoof build info", - description = "Spoof the information about the current build.", - use = false, -) { - val board by stringOption( - key = "board", - default = null, - title = "Board", - description = "The name of the underlying board, like \"goldfish\".", - ) - - val bootloader by stringOption( - key = "bootloader", - default = null, - title = "Bootloader", - description = "The system bootloader version number.", - ) - - val brand by stringOption( - key = "brand", - default = null, - title = "Brand", - description = "The consumer-visible brand with which the product/hardware will be associated, if any.", - ) - - val cpuAbi by stringOption( - key = "cpu-abi", - default = null, - title = "CPU ABI", - description = "This field was deprecated in API level 21. Use SUPPORTED_ABIS instead.", - ) - - val cpuAbi2 by stringOption( - key = "cpu-abi-2", - default = null, - title = "CPU ABI 2", - description = "This field was deprecated in API level 21. Use SUPPORTED_ABIS instead.", - ) - - val device by stringOption( - key = "device", - default = null, - title = "Device", - description = "The name of the industrial design.", - ) - - val display by stringOption( - key = "display", - default = null, - title = "Display", - description = "A build ID string meant for displaying to the user.", - ) - - val fingerprint by stringOption( - key = "fingerprint", - default = null, - title = "Fingerprint", - description = "A string that uniquely identifies this build.", - ) - - val hardware by stringOption( - key = "hardware", - default = null, - title = "Hardware", - description = "The name of the hardware (from the kernel command line or /proc).", - ) - - val host by stringOption( - key = "host", - default = null, - title = "Host", - description = "The host.", - ) - - val id by stringOption( - key = "id", - default = null, - title = "ID", - description = "Either a changelist number, or a label like \"M4-rc20\".", - ) - - val manufacturer by stringOption( - key = "manufacturer", - default = null, - title = "Manufacturer", - description = "The manufacturer of the product/hardware.", - ) - - val model by stringOption( - key = "model", - default = null, - title = "Model", - description = "The end-user-visible name for the end product.", - ) - - val odmSku by stringOption( - key = "odm-sku", - default = null, - title = "ODM SKU", - description = "The SKU of the device as set by the original design manufacturer (ODM).", - ) - - val product by stringOption( - key = "product", - default = null, - title = "Product", - description = "The name of the overall product.", - ) - - val radio by stringOption( - key = "radio", - default = null, - title = "Radio", - description = "This field was deprecated in API level 15. " + - "The radio firmware version is frequently not available when this class is initialized, " + - "leading to a blank or \"unknown\" value for this string. Use getRadioVersion() instead.", - ) - - val serial by stringOption( - key = "serial", - default = null, - title = "Serial", - description = "This field was deprecated in API level 26. Use getSerial() instead.", - ) - - val sku by stringOption( - key = "sku", - default = null, - title = "SKU", - description = "The SKU of the hardware (from the kernel command line).", - ) - - val socManufacturer by stringOption( - key = "soc-manufacturer", - default = null, - title = "SOC Manufacturer", - description = "The manufacturer of the device's primary system-on-chip.", - ) - - val socModel by stringOption( - key = "soc-model", - default = null, - title = "SOC Model", - description = "The model name of the device's primary system-on-chip.", - ) - - val tags by stringOption( - key = "tags", - default = null, - title = "Tags", - description = "Comma-separated tags describing the build, like \"unsigned,debug\".", - ) - - val time by longOption( - key = "time", - default = null, - title = "Time", - description = "The time at which the build was produced, given in milliseconds since the UNIX epoch.", - ) - - val type by stringOption( - key = "type", - default = null, - title = "Type", - description = "The type of build, like \"user\" or \"eng\".", - ) - - val user by stringOption( - key = "user", - default = null, - title = "User", - description = "The user.", - ) - - dependsOn( - baseSpoofBuildInfoPatch { - BuildInfo( - board, - bootloader, - brand, - cpuAbi, - cpuAbi2, - device, - display, - fingerprint, - hardware, - host, - id, - manufacturer, - model, - odmSku, - product, - radio, - serial, - sku, - socManufacturer, - socModel, - tags, - time, - type, - user, - ) - }, - - ) -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/location/hide/HideMockLocationPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/location/hide/HideMockLocationPatch.kt deleted file mode 100644 index b17eea9..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/location/hide/HideMockLocationPatch.kt +++ /dev/null @@ -1,50 +0,0 @@ -@file:Suppress("unused") - -package app.revanced.patches.all.misc.connectivity.location.hide - -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.all.misc.transformation.IMethodCall -import app.revanced.patches.all.misc.transformation.fromMethodReference -import app.revanced.patches.all.misc.transformation.transformInstructionsPatch -import app.revanced.util.getReference -import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference - -@Suppress("unused") -val hideMockLocationPatch = bytecodePatch( - name = "Hide mock location", - description = "Prevents the app from knowing the device location is being mocked by a third party app.", - use = false, -) { - dependsOn( - transformInstructionsPatch( - filterMap = filter@{ _, _, instruction, instructionIndex -> - val reference = instruction.getReference() ?: return@filter null - if (fromMethodReference(reference) == null) return@filter null - - instruction to instructionIndex - }, - transform = { method, entry -> - val (instruction, index) = entry - instruction as FiveRegisterInstruction - - // Replace return value with a constant `false` boolean. - method.replaceInstruction( - index + 1, - "const/4 v${instruction.registerC}, 0x0", - ) - }, - ), - ) -} - -private enum class MethodCall( - override val definedClassName: String, - override val methodName: String, - override val methodParams: Array, - override val returnType: String, -) : IMethodCall { - IsMock("Landroid/location/Location;", "isMock", emptyArray(), "Z"), - IsFromMockProvider("Landroid/location/Location;", "isFromMockProvider", emptyArray(), "Z"), -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/telephony/sim/spoof/SpoofSimCountryPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/telephony/sim/spoof/SpoofSimCountryPatch.kt deleted file mode 100644 index b50ccfc..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/telephony/sim/spoof/SpoofSimCountryPatch.kt +++ /dev/null @@ -1,105 +0,0 @@ -package app.revanced.patches.all.misc.connectivity.telephony.sim.spoof - -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patcher.patch.stringOption -import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.all.misc.transformation.transformInstructionsPatch -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference -import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference -import com.android.tools.smali.dexlib2.util.MethodUtil -import java.util.* - -@Suppress("unused") -val spoofSimCountryPatch = bytecodePatch( - name = "Spoof SIM country", - description = "Spoofs country information returned by the SIM card provider.", - use = false, -) { - val countries = Locale.getISOCountries().associateBy { Locale("", it).displayCountry } - - fun isoCountryPatchOption( - key: String, - title: String, - ) = stringOption( - key, - null, - countries, - title, - "ISO-3166-1 alpha-2 country code equivalent for the SIM provider's country code.", - false, - validator = { it: String? -> it == null || it.uppercase() in countries.values }, - ) - - val networkCountryIso by isoCountryPatchOption( - "networkCountryIso", - "Network ISO Country Code", - ) - - val simCountryIso by isoCountryPatchOption( - "simCountryIso", - "Sim ISO Country Code", - ) - - dependsOn( - transformInstructionsPatch( - filterMap = { _, _, instruction, instructionIndex -> - if (instruction !is ReferenceInstruction) return@transformInstructionsPatch null - - val reference = instruction.reference as? MethodReference ?: return@transformInstructionsPatch null - - val match = MethodCall.entries.firstOrNull { search -> - MethodUtil.methodSignaturesMatch(reference, search.reference) - } ?: return@transformInstructionsPatch null - - val iso = when (match) { - MethodCall.NetworkCountryIso -> networkCountryIso - MethodCall.SimCountryIso -> simCountryIso - }?.lowercase() - - iso?.let { instructionIndex to it } - }, - transform = { mutableMethod, entry: Pair -> - transformMethodCall(entry, mutableMethod) - }, - ), - ) -} - -private fun transformMethodCall( - entry: Pair, - mutableMethod: MutableMethod, -) { - val (instructionIndex, methodCallValue) = entry - - val register = mutableMethod.getInstruction(instructionIndex + 1).registerA - - mutableMethod.replaceInstruction( - instructionIndex + 1, - "const-string v$register, \"$methodCallValue\"", - ) -} - -private enum class MethodCall( - val reference: MethodReference, -) { - NetworkCountryIso( - ImmutableMethodReference( - "Landroid/telephony/TelephonyManager;", - "getNetworkCountryIso", - emptyList(), - "Ljava/lang/String;", - ), - ), - SimCountryIso( - ImmutableMethodReference( - "Landroid/telephony/TelephonyManager;", - "getSimCountryIso", - emptyList(), - "Ljava/lang/String;", - ), - ), -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/wifi/spoof/SpoofWifiPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/wifi/spoof/SpoofWifiPatch.kt deleted file mode 100644 index f6b01cd..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/wifi/spoof/SpoofWifiPatch.kt +++ /dev/null @@ -1,225 +0,0 @@ -package app.revanced.patches.all.misc.connectivity.wifi.spoof - -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.all.misc.transformation.IMethodCall -import app.revanced.patches.all.misc.transformation.filterMapInstruction35c -import app.revanced.patches.all.misc.transformation.transformInstructionsPatch - -private const val EXTENSION_CLASS_DESCRIPTOR_PREFIX = - "Lapp/revanced/extension/all/connectivity/wifi/spoof/SpoofWifiPatch" - -private const val EXTENSION_CLASS_DESCRIPTOR = "$EXTENSION_CLASS_DESCRIPTOR_PREFIX;" - -@Suppress("unused") -val spoofWifiPatch = bytecodePatch( - name = "Spoof Wi-Fi connection", - description = "Spoofs an existing Wi-Fi connection.", - use = false, -) { - extendWith("extensions/all/misc/connectivity/wifi/spoof/spoof-wifi.rve") - - dependsOn( - transformInstructionsPatch( - filterMap = { classDef, _, instruction, instructionIndex -> - filterMapInstruction35c( - EXTENSION_CLASS_DESCRIPTOR_PREFIX, - classDef, - instruction, - instructionIndex, - ) - }, - transform = { method, entry -> - val (methodType, instruction, instructionIndex) = entry - methodType.replaceInvokeVirtualWithExtension( - EXTENSION_CLASS_DESCRIPTOR, - method, - instruction, - instructionIndex, - ) - }, - ), - ) -} - -// Information about method calls we want to replace -@Suppress("unused") -private enum class MethodCall( - override val definedClassName: String, - override val methodName: String, - override val methodParams: Array, - override val returnType: String, -) : IMethodCall { - GetSystemService1( - "Landroid/content/Context;", - "getSystemService", - arrayOf("Ljava/lang/String;"), - "Ljava/lang/Object;", - ), - GetSystemService2( - "Landroid/content/Context;", - "getSystemService", - arrayOf("Ljava/lang/Class;"), - "Ljava/lang/Object;", - ), - GetActiveNetworkInfo( - "Landroid/net/ConnectivityManager;", - "getActiveNetworkInfo", - arrayOf(), - "Landroid/net/NetworkInfo;", - ), - IsConnected( - "Landroid/net/NetworkInfo;", - "isConnected", - arrayOf(), - "Z", - ), - IsConnectedOrConnecting( - "Landroid/net/NetworkInfo;", - "isConnectedOrConnecting", - arrayOf(), - "Z", - ), - IsAvailable( - "Landroid/net/NetworkInfo;", - "isAvailable", - arrayOf(), - "Z", - ), - GetState( - "Landroid/net/NetworkInfo;", - "getState", - arrayOf(), - "Landroid/net/NetworkInfo\$State;", - ), - GetDetailedState( - "Landroid/net/NetworkInfo;", - "getDetailedState", - arrayOf(), - "Landroid/net/NetworkInfo\$DetailedState;", - ), - IsActiveNetworkMetered( - "Landroid/net/ConnectivityManager;", - "isActiveNetworkMetered", - arrayOf(), - "Z", - ), - GetActiveNetwork( - "Landroid/net/ConnectivityManager;", - "getActiveNetwork", - arrayOf(), - "Landroid/net/Network;", - ), - GetNetworkInfo( - "Landroid/net/ConnectivityManager;", - "getNetworkInfo", - arrayOf("Landroid/net/Network;"), - "Landroid/net/NetworkInfo;", - ), - HasTransport( - "Landroid/net/NetworkCapabilities;", - "hasTransport", - arrayOf("I"), - "Z", - ), - HasCapability( - "Landroid/net/NetworkCapabilities;", - "hasCapability", - arrayOf("I"), - "Z", - ), - RegisterBestMatchingNetworkCallback( - "Landroid/net/ConnectivityManager;", - "registerBestMatchingNetworkCallback", - arrayOf( - "Landroid/net/NetworkRequest;", - "Landroid/net/ConnectivityManager\$NetworkCallback;", - "Landroid/os/Handler;", - ), - "V", - ), - RegisterDefaultNetworkCallback1( - "Landroid/net/ConnectivityManager;", - "registerDefaultNetworkCallback", - arrayOf("Landroid/net/ConnectivityManager\$NetworkCallback;"), - "V", - ), - RegisterDefaultNetworkCallback2( - "Landroid/net/ConnectivityManager;", - "registerDefaultNetworkCallback", - arrayOf("Landroid/net/ConnectivityManager\$NetworkCallback;", "Landroid/os/Handler;"), - "V", - ), - RegisterNetworkCallback1( - "Landroid/net/ConnectivityManager;", - "registerNetworkCallback", - arrayOf("Landroid/net/NetworkRequest;", "Landroid/net/ConnectivityManager\$NetworkCallback;"), - "V", - ), - RegisterNetworkCallback2( - "Landroid/net/ConnectivityManager;", - "registerNetworkCallback", - arrayOf("Landroid/net/NetworkRequest;", "Landroid/app/PendingIntent;"), - "V", - ), - RegisterNetworkCallback3( - "Landroid/net/ConnectivityManager;", - "registerNetworkCallback", - arrayOf( - "Landroid/net/NetworkRequest;", - "Landroid/net/ConnectivityManager\$NetworkCallback;", - "Landroid/os/Handler;", - ), - "V", - ), - RequestNetwork1( - "Landroid/net/ConnectivityManager;", - "requestNetwork", - arrayOf("Landroid/net/NetworkRequest;", "Landroid/net/ConnectivityManager\$NetworkCallback;"), - "V", - ), - RequestNetwork2( - "Landroid/net/ConnectivityManager;", - "requestNetwork", - arrayOf("Landroid/net/NetworkRequest;", "Landroid/net/ConnectivityManager\$NetworkCallback;", "I"), - "V", - ), - RequestNetwork3( - "Landroid/net/ConnectivityManager;", - "requestNetwork", - arrayOf( - "Landroid/net/NetworkRequest;", - "Landroid/net/ConnectivityManager\$NetworkCallback;", - "Landroid/os/Handler;", - ), - "V", - ), - RequestNetwork4( - "Landroid/net/ConnectivityManager;", - "requestNetwork", - arrayOf("Landroid/net/NetworkRequest;", "Landroid/app/PendingIntent;"), - "V", - ), - RequestNetwork5( - "Landroid/net/ConnectivityManager;", - "requestNetwork", - arrayOf( - "Landroid/net/NetworkRequest;", - "Landroid/net/ConnectivityManager\$NetworkCallback;", - "Landroid/os/Handler;", - "I", - ), - "V", - ), - UnregisterNetworkCallback1( - "Landroid/net/ConnectivityManager;", - "unregisterNetworkCallback", - arrayOf("Landroid/net/ConnectivityManager\$NetworkCallback;"), - "V", - ), - UnregisterNetworkCallback2( - "Landroid/net/ConnectivityManager;", - "unregisterNetworkCallback", - arrayOf("Landroid/app/PendingIntent;"), - "V", - ), -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/debugging/EnableAndroidDebuggingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/debugging/EnableAndroidDebuggingPatch.kt deleted file mode 100644 index fc7e33c..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/debugging/EnableAndroidDebuggingPatch.kt +++ /dev/null @@ -1,22 +0,0 @@ -package app.revanced.patches.all.misc.debugging - -import app.revanced.patcher.patch.resourcePatch -import org.w3c.dom.Element - -val enableAndroidDebuggingPatch = resourcePatch( - name = "Enable Android debugging", - description = "Enables Android debugging capabilities. This can slow down the app.", - use = false, -) { - execute { - document("AndroidManifest.xml").use { document -> - val applicationNode = - document - .getElementsByTagName("application") - .item(0) as Element - - // set application as debuggable - applicationNode.setAttribute("android:debuggable", "true") - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/directory/ChangeDataDirectoryLocationPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/directory/ChangeDataDirectoryLocationPatch.kt deleted file mode 100644 index 8046c11..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/directory/ChangeDataDirectoryLocationPatch.kt +++ /dev/null @@ -1,19 +0,0 @@ -package app.revanced.patches.all.misc.directory - -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.all.misc.directory.documentsprovider.exportInternalDataDocumentsProviderPatch - -@Suppress("unused") -@Deprecated( - "Superseded by internalDataDocumentsProviderPatch", - ReplaceWith("internalDataDocumentsProviderPatch"), -) -val changeDataDirectoryLocationPatch = bytecodePatch( - // name = "Change data directory location", - description = "Changes the data directory in the application from " + - "the app internal storage directory to /sdcard/android/data accessible by root-less devices." + - "Using this patch can cause unexpected issues with some apps.", - use = false, -) { - dependsOn(exportInternalDataDocumentsProviderPatch) -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/directory/documentsprovider/ExportInternalDataDocumentsProviderPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/directory/documentsprovider/ExportInternalDataDocumentsProviderPatch.kt deleted file mode 100644 index 187fd23..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/directory/documentsprovider/ExportInternalDataDocumentsProviderPatch.kt +++ /dev/null @@ -1,58 +0,0 @@ -package app.revanced.patches.all.misc.directory.documentsprovider - -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patcher.patch.resourcePatch -import app.revanced.util.asSequence -import app.revanced.util.getNode - -@Suppress("unused") -val exportInternalDataDocumentsProviderPatch = resourcePatch( - name = "Export internal data documents provider", - description = "Exports a documents provider that grants access to the internal data directory of this app " + - "to file managers and other apps that support the Storage Access Framework.", - use = false, -) { - dependsOn( - bytecodePatch { - extendWith("extensions/all/misc/directory/documentsprovider/export-internal-data-documents-provider.rve") - }, - ) - - execute { - val documentsProviderClass = - "app.revanced.extension.all.misc.directory.documentsprovider.InternalDataDocumentsProvider" - - document("AndroidManifest.xml").use { document -> - // Check if the provider is already declared - if (document.getElementsByTagName("provider") - .asSequence() - .any { it.attributes.getNamedItem("android:name")?.nodeValue == documentsProviderClass } - ) { - return@execute - } - - val authority = - document.getNode("manifest").attributes.getNamedItem("package").let { - // Select a URI authority name that is unique to the current app - "${it.nodeValue}.$documentsProviderClass" - } - - // Register the documents provider - with(document.getNode("application")) { - document.createElement("provider").apply { - setAttribute("android:name", documentsProviderClass) - setAttribute("android:authorities", authority) - setAttribute("android:exported", "true") - setAttribute("android:grantUriPermissions", "true") - setAttribute("android:permission", "android.permission.MANAGE_DOCUMENTS") - - document.createElement("intent-filter").apply { - document.createElement("action").apply { - setAttribute("android:name", "android.content.action.DOCUMENTS_PROVIDER") - }.let(this::appendChild) - }.let(this::appendChild) - }.let(this::appendChild) - } - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/hex/HexPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/hex/HexPatch.kt deleted file mode 100644 index a8bb805..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/hex/HexPatch.kt +++ /dev/null @@ -1,56 +0,0 @@ -package app.revanced.patches.all.misc.hex - -import app.revanced.patcher.patch.PatchException -import app.revanced.patcher.patch.rawResourcePatch -import app.revanced.patcher.patch.stringsOption -import app.revanced.patches.shared.misc.hex.Replacement -import app.revanced.patches.shared.misc.hex.hexPatch -import app.revanced.util.Utils.trimIndentMultiline - -@Suppress("unused") -val hexPatch = rawResourcePatch( - name = "Hex", - description = "Replaces a hexadecimal patterns of bytes of files in an APK.", - use = false, -) { - // TODO: Instead of stringArrayOption, use a custom option type to work around - // https://github.com/ReVanced/revanced-library/issues/48. - // Replace the custom option type with a stringArrayOption once the issue is resolved. - val replacements by stringsOption( - key = "replacements", - title = "Replacements", - description = """ - Hexadecimal patterns to search for and replace with another in a target file. - - A pattern is a sequence of case insensitive strings, each representing hexadecimal bytes, separated by spaces. - An example pattern is 'aa 01 02 FF'. - - Every pattern must be followed by a pipe ('|'), the replacement pattern, - another pipe ('|'), and the path to the file to make the changes in relative to the APK root. - The replacement pattern must have the same length as the original pattern. - - Full example of a valid input: - 'aa 01 02 FF|00 00 00 00|path/to/file' - """.trimIndentMultiline(), - required = true, - ) - - dependsOn( - hexPatch { - replacements!!.map { from -> - val (pattern, replacementPattern, targetFilePath) = try { - from.split("|", limit = 3) - } catch (e: Exception) { - throw PatchException( - "Invalid input: $from.\n" + - "Every pattern must be followed by a pipe ('|'), " + - "the replacement pattern, another pipe ('|'), " + - "and the path to the file to make the changes in relative to the APK root. ", - ) - } - - Replacement(pattern, replacementPattern, targetFilePath) - }.toSet() - }, - ) -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/interaction/gestures/PredictiveBackGesturePatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/interaction/gestures/PredictiveBackGesturePatch.kt deleted file mode 100644 index 29f6444..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/interaction/gestures/PredictiveBackGesturePatch.kt +++ /dev/null @@ -1,24 +0,0 @@ -package app.revanced.patches.all.misc.interaction.gestures - -import app.revanced.patcher.patch.resourcePatch - -@Suppress("unused") -val predictiveBackGesturePatch = resourcePatch( - name = "Predictive back gesture", - description = "Enables the predictive back gesture introduced on Android 13.", - use = false, -) { - execute { - val flag = "android:enableOnBackInvokedCallback" - - document("AndroidManifest.xml").use { document -> - with(document.getElementsByTagName("application").item(0)) { - if (attributes.getNamedItem(flag) != null) return@with - - document.createAttribute(flag) - .apply { value = "true" } - .let(attributes::setNamedItem) - } - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/network/OverrideCertificatePinningPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/network/OverrideCertificatePinningPatch.kt deleted file mode 100644 index c85f4c3..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/network/OverrideCertificatePinningPatch.kt +++ /dev/null @@ -1,57 +0,0 @@ -package app.revanced.patches.all.misc.network - -import app.revanced.patcher.patch.resourcePatch -import app.revanced.patches.all.misc.debugging.enableAndroidDebuggingPatch -import app.revanced.util.Utils.trimIndentMultiline -import org.w3c.dom.Element -import java.io.File - -@Suppress("unused") -val overrideCertificatePinningPatch = resourcePatch( - name = "Override certificate pinning", - description = "Overrides certificate pinning, allowing to inspect traffic via a proxy.", - use = false, -) { - dependsOn(enableAndroidDebuggingPatch) - - execute { - val resXmlDirectory = get("res/xml") - - // Add android:networkSecurityConfig="@xml/network_security_config" and the "networkSecurityConfig" attribute if it does not exist. - document("AndroidManifest.xml").use { document -> - val applicationNode = document.getElementsByTagName("application").item(0) as Element - - if (!applicationNode.hasAttribute("networkSecurityConfig")) { - document.createAttribute("android:networkSecurityConfig") - .apply { value = "@xml/network_security_config" }.let(applicationNode.attributes::setNamedItem) - } - } - - // In case the file does not exist create the "network_security_config.xml" file. - File(resXmlDirectory, "network_security_config.xml").apply { - writeText( - """ - - - - - - - - - - - - - - - - """.trimIndentMultiline(), - ) - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/packagename/ChangePackageNamePatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/packagename/ChangePackageNamePatch.kt deleted file mode 100644 index 4a6443a..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/packagename/ChangePackageNamePatch.kt +++ /dev/null @@ -1,123 +0,0 @@ -package app.revanced.patches.all.misc.packagename - -import app.revanced.patcher.patch.* -import app.revanced.util.asSequence -import app.revanced.util.getNode -import org.w3c.dom.Element -import java.util.logging.Logger - -lateinit var packageNameOption: Option - -/** - * Set the package name to use. - * If this is called multiple times, the first call will set the package name. - * - * @param fallbackPackageName The package name to use if the user has not already specified a package name. - * @return The package name that was set. - * @throws OptionException.ValueValidationException If the package name is invalid. - */ -fun setOrGetFallbackPackageName(fallbackPackageName: String): String { - val packageName = packageNameOption.value!! - - return if (packageName == packageNameOption.default) { - fallbackPackageName.also { packageNameOption.value = it } - } else { - packageName - } -} - -val changePackageNamePatch = resourcePatch( - name = "Change package name", - description = "Appends \".revanced\" to the package name by default. " + - "Changing the package name of the app can lead to unexpected issues.", - use = false, -) { - packageNameOption = stringOption( - key = "packageName", - default = "Default", - values = mapOf("Default" to "Default"), - title = "Package name", - description = "The name of the package to rename the app to.", - required = true, - ) { - it == "Default" || it!!.matches(Regex("^[a-z]\\w*(\\.[a-z]\\w*)+\$")) - } - - val updatePermissions by booleanOption( - key = "updatePermissions", - default = false, - title = "Update permissions", - description = "Update compatibility receiver permissions. " + - "Enabling this can fix installation errors, but this can also break features in certain apps.", - ) - - val updateProviders by booleanOption( - key = "updateProviders", - default = false, - title = "Update providers", - description = "Update provider names declared by the app. " + - "Enabling this can fix installation errors, but this can also break features in certain apps.", - ) - - finalize { - /** - * Apps that are confirmed to not work correctly with this patch. - * This is not an exhaustive list, and is only the apps with - * ReVanced specific patches and are confirmed incompatible with this patch. - */ - val incompatibleAppPackages = setOf( - // Cannot log in, settings menu is broken. - "com.reddit.frontpage", - - // Patches and installs but crashes on launch. - "com.duolingo", - "com.twitter.android", - "tv.twitch.android.app", - ) - - document("AndroidManifest.xml").use { document -> - val manifest = document.getNode("manifest") as Element - val packageName = manifest.getAttribute("package") - - if (incompatibleAppPackages.contains(packageName)) { - return@finalize Logger.getLogger(this::class.java.name).severe( - "'$packageName' does not work correctly with \"Change package name\"", - ) - } - - val replacementPackageName = packageNameOption.value - val newPackageName = if (replacementPackageName != packageNameOption.default) { - replacementPackageName!! - } else { - "$packageName.revanced" - } - - manifest.setAttribute("package", newPackageName) - - if (updatePermissions == true) { - val permissions = manifest.getElementsByTagName("permission").asSequence() - val usesPermissions = manifest.getElementsByTagName("uses-permission").asSequence() - - val receiverNotExported = "DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION" - - (permissions + usesPermissions) - .map { it as Element } - .filter { it.getAttribute("android:name") == "$packageName.$receiverNotExported" } - .forEach { it.setAttribute("android:name", "$newPackageName.$receiverNotExported") } - } - - if (updateProviders == true) { - val providers = manifest.getElementsByTagName("provider").asSequence() - - for (node in providers) { - val provider = node as Element - - val authorities = provider.getAttribute("android:authorities") - if (!authorities.startsWith("$packageName.")) continue - - provider.setAttribute("android:authorities", authorities.replace(packageName, newPackageName)) - } - } - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt deleted file mode 100644 index f32986e..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt +++ /dev/null @@ -1,396 +0,0 @@ -package app.revanced.patches.all.misc.resources - -import app.revanced.patcher.patch.Patch -import app.revanced.patcher.patch.PatchException -import app.revanced.patcher.patch.resourcePatch -import app.revanced.patcher.util.Document -import app.revanced.util.* -import app.revanced.util.resource.ArrayResource -import app.revanced.util.resource.BaseResource -import app.revanced.util.resource.StringResource -import org.w3c.dom.Node - -/** - * An identifier of an app. For example, `youtube`. - */ -private typealias AppId = String - -/** - * An identifier of a patch. For example, `ad.general.HideAdsPatch`. - */ -private typealias PatchId = String - -/** - * A set of resources of a patch. - */ -private typealias PatchResources = MutableSet - -/** - * A map of resources belonging to a patch. - */ -private typealias AppResources = MutableMap - -/** - * A map of resources belonging to an app. - */ -private typealias Resources = MutableMap - -/** - * The value of a resource. - * For example, `values` or `values-de`. - */ -private typealias Value = String - -/** - * A set of resources mapped by their value. - */ -private typealias MutableResources = MutableMap> - -/** - * A map of all resources associated by their value staged by [addResourcesPatch]. - */ -private lateinit var stagedResources: Map - -/** - * A map of all resources added to the app by [addResourcesPatch]. - */ -private val resources: MutableResources = mutableMapOf() - -/** - * Map of Crowdin locales to Android resource locale names. - * - * Fixme: Instead this patch should detect what locale regions are present in both patches and the target app, - * and automatically merge into the appropriate existing target file. - * So if a target app has only 'es', then the Crowdin file of 'es-rES' should merge into that. - * But if a target app has specific regions (such as 'pt-rBR'), - * then the Crowdin region specific file should merged into that. - */ -private val locales = mapOf( - "af-rZA" to "af", - "am-rET" to "am", - "ar-rSA" to "ar", - "as-rIN" to "as", - "az-rAZ" to "az", - "be-rBY" to "be", - "bg-rBG" to "bg", - "bn-rBD" to "bn", - "bs-rBA" to "bs", - "ca-rES" to "ca", - "cs-rCZ" to "cs", - "da-rDK" to "da", - "de-rDE" to "de", - "el-rGR" to "el", - "es-rES" to "es", - "et-rEE" to "et", - "eu-rES" to "eu", - "fa-rIR" to "fa", - "fi-rFI" to "fi", - "fil-rPH" to "tl", - "fr-rFR" to "fr", - "ga-rIE" to "ga", - "gl-rES" to "gl", - "gu-rIN" to "gu", - "hi-rIN" to "hi", - "hr-rHR" to "hr", - "hu-rHU" to "hu", - "hy-rAM" to "hy", - "in-rID" to "in", - "is-rIS" to "is", - "it-rIT" to "it", - "iw-rIL" to "iw", - "ja-rJP" to "ja", - "ka-rGE" to "ka", - "kk-rKZ" to "kk", - "km-rKH" to "km", - "kn-rIN" to "kn", - "ko-rKR" to "ko", - "ky-rKG" to "ky", - "lo-rLA" to "lo", - "lt-rLT" to "lt", - "lv-rLV" to "lv", - "mk-rMK" to "mk", - "ml-rIN" to "ml", - "mn-rMN" to "mn", - "mr-rIN" to "mr", - "ms-rMY" to "ms", - "my-rMM" to "my", - "nb-rNO" to "nb", - "ne-rIN" to "ne", - "nl-rNL" to "nl", - "or-rIN" to "or", - "pa-rIN" to "pa", - "pl-rPL" to "pl", - "pt-rBR" to "pt-rBR", - "pt-rPT" to "pt-rPT", - "ro-rRO" to "ro", - "ru-rRU" to "ru", - "si-rLK" to "si", - "sk-rSK" to "sk", - "sl-rSI" to "sl", - "sq-rAL" to "sq", - "sr-rCS" to "b+sr+Latn", - "sr-rSP" to "sr", - "sv-rSE" to "sv", - "sw-rKE" to "sw", - "ta-rIN" to "ta", - "te-rIN" to "te", - "th-rTH" to "th", - "tl-rPH" to "tl", - "tr-rTR" to "tr", - "uk-rUA" to "uk", - "ur-rIN" to "ur", - "uz-rUZ" to "uz", - "vi-rVN" to "vi", - "zh-rCN" to "zh-rCN", - "zh-rTW" to "zh-rTW", - "zu-rZA" to "zu", -) - -/** - * Adds a [BaseResource] to the map using [MutableMap.getOrPut]. - * - * @param value The value of the resource. For example, `values` or `values-de`. - * @param resource The resource to add. - * - * @return True if the resource was added, false if it already existed. - */ -fun addResource( - value: Value, - resource: BaseResource, -) = resources.getOrPut(value, ::mutableSetOf).add(resource) - -/** - * Adds a list of [BaseResource]s to the map using [MutableMap.getOrPut]. - * - * @param value The value of the resource. For example, `values` or `values-de`. - * @param resources The resources to add. - * - * @return True if the resources were added, false if they already existed. - */ -fun addResources( - value: Value, - resources: Iterable, -) = app.revanced.patches.all.misc.resources.resources.getOrPut(value, ::mutableSetOf).addAll(resources) - -/** - * Adds a [StringResource]. - * - * @param name The name of the string resource. - * @param value The value of the string resource. - * @param formatted Whether the string resource is formatted. Defaults to `true`. - * @param resourceValue The value of the resource. For example, `values` or `values-de`. - * - * @return True if the resource was added, false if it already existed. - */ -fun addResources( - name: String, - value: String, - formatted: Boolean = true, - resourceValue: Value = "values", -) = addResource(resourceValue, StringResource(name, value, formatted)) - -/** - * Adds an [ArrayResource]. - * - * @param name The name of the array resource. - * @param items The items of the array resource. - * - * @return True if the resource was added, false if it already existed. - */ -fun addResources( - name: String, - items: List, -) = addResource("values", ArrayResource(name, items)) - -/** - * Puts all resources of any [Value] staged in [stagedResources] for the [Patch] to [addResources]. - * - * @param patch The [Patch] of the patch to stage resources for. - * @param parseIds A function that parses a set of [PatchId] each mapped to an [AppId] from the given [Patch]. - * This is used to access the resources in [addResources] to stage them in [stagedResources]. - * The default implementation assumes that the [Patch] has a name and declares packages it is compatible with. - * - * @return True if any resources were added, false if none were added. - * - * @see addResourcesPatch - */ -fun addResources( - patch: Patch<*>, - parseIds: (Patch<*>) -> Map> = { - val patchId = patch.name ?: throw PatchException("Patch has no name") - val packages = patch.compatiblePackages ?: throw PatchException("Patch has no compatible packages") - - buildMap> { - packages.forEach { (appId, _) -> - getOrPut(appId) { mutableSetOf() }.add(patchId) - } - } - }, -): Boolean { - var result = false - - // Stage resources for the given patch to addResourcesPatch associated with their value. - parseIds(patch).forEach { (appId, patchIds) -> - patchIds.forEach { patchId -> - stagedResources.forEach { (value, resources) -> - resources[appId]?.get(patchId)?.let { patchResources -> - if (addResources(value, patchResources)) result = true - } - } - } - } - - return result -} - -/** - * Puts all resources for the given [appId] and [patchId] staged in [addResources] to [addResourcesPatch]. - * - * - * @return True if any resources were added, false if none were added. - * - * @see addResourcesPatch - */ -fun addResources( - appId: AppId, - patchId: String, -) = stagedResources.forEach { (value, resources) -> - resources[appId]?.get(patchId)?.let { patchResources -> - addResources(value, patchResources) - } -} - -val addResourcesPatch = resourcePatch( - description = "Add resources such as strings or arrays to the app.", -) { - /* - The strategy of this patch is to stage resources present in `/resources/addresources`. - These resources are organized by their respective value and patch. - - On addResourcesPatch#execute, all resources are staged in a temporary map. - After that, other patches that depend on addResourcesPatch can call - addResourcesPatch#invoke(Patch) to stage resources belonging to that patch - from the temporary map to addResourcesPatch. - - After all patches that depend on addResourcesPatch have been executed, - addResourcesPatch#finalize is finally called to add all staged resources to the app. - */ - execute { - stagedResources = buildMap { - /** - * Puts resources under `/resources/addresources//.xml` into the map. - * - * @param sourceValue The source value of the resource. For example, `values` or `values-de-rDE`. - * @param destValue The destination value of the resource. For example, 'values' or 'values-de'. - * @param resourceKind The kind of the resource. For example, `strings` or `arrays`. - * @param transform A function that transforms the [Node]s from the XML files to a [BaseResource]. - */ - fun addResources( - sourceValue: Value, - destValue: Value = sourceValue, - resourceKind: String, - transform: (Node) -> BaseResource, - ) { - inputStreamFromBundledResource( - "addresources", - "$sourceValue/$resourceKind.xml", - )?.let { stream -> - // Add the resources associated with the given value to the map, - // instead of overwriting it. - // This covers the example case such as adding strings and arrays of the same value. - getOrPut(destValue, ::mutableMapOf).apply { - document(stream).use { document -> - document.getElementsByTagName("app").asSequence().forEach { app -> - val appId = app.attributes.getNamedItem("id").textContent - - getOrPut(appId, ::mutableMapOf).apply { - app.forEachChildElement { patch -> - val patchId = patch.attributes.getNamedItem("id").textContent - - getOrPut(patchId, ::mutableSetOf).apply { - patch.forEachChildElement { resourceNode -> - val resource = transform(resourceNode) - - add(resource) - } - } - } - } - } - } - } - } - } - - // Stage all resources to a temporary map. - // Staged resources consumed by addResourcesPatch#invoke(Patch) - // are later used in addResourcesPatch#finalize. - try { - val addStringResources = { source: Value, dest: Value -> - addResources(source, dest, "strings", StringResource::fromNode) - } - locales.forEach { (source, dest) -> addStringResources("values-$source", "values-$dest") } - addStringResources("values", "values") - - addResources("values", "values", "arrays", ArrayResource::fromNode) - } catch (e: Exception) { - throw PatchException("Failed to read resources", e) - } - } - } - - /** - * Adds all resources staged in [addResourcesPatch] to the app. - * This is called after all patches that depend on [addResourcesPatch] have been executed. - */ - finalize { - operator fun MutableMap>.invoke( - value: Value, - resource: BaseResource, - ) { - // TODO: Fix open-closed principle violation by modifying BaseResource#serialize so that it accepts - // a Value and the map of documents. It will then get or put the document suitable for its resource type - // to serialize itself to it. - val resourceFileName = - when (resource) { - is StringResource -> "strings" - is ArrayResource -> "arrays" - else -> throw NotImplementedError("Unsupported resource type") - } - - getOrPut(resourceFileName) { - this@finalize["res/$value/$resourceFileName.xml"].also { - it.parentFile?.mkdirs() - - if (it.createNewFile()) { - it.writeText("\n\n") - } - } - - document("res/$value/$resourceFileName.xml").let { document -> - - // Save the target node here as well - // in order to avoid having to call document.getNode("resources") - // but also save the document so that it can be closed later. - document to document.getNode("resources") - } - }.let { (_, targetNode) -> - targetNode.addResource(resource) { invoke(value, it) } - } - } - - resources.forEach { (value, resources) -> - // A map of document associated by their kind (e.g. strings, arrays). - // Each document is accompanied by the target node to which resources are added. - // A map is used because Map#getOrPut allows opening a new document for the duration of a resource value. - // This is done to prevent having to open the files for every resource that is added. - // Instead, it is cached once and reused for resources of the same value. - // This map is later accessed to close all documents for the current resource value. - val documents = mutableMapOf>() - - resources.forEach { resource -> documents(value, resource) } - - documents.values.forEach { (document, _) -> document.close() } - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/screencapture/RemoveScreenCaptureRestrictionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/screencapture/RemoveScreenCaptureRestrictionPatch.kt deleted file mode 100644 index a65c19d..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/screencapture/RemoveScreenCaptureRestrictionPatch.kt +++ /dev/null @@ -1,83 +0,0 @@ -package app.revanced.patches.all.misc.screencapture - -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patcher.patch.resourcePatch -import app.revanced.patches.all.misc.transformation.IMethodCall -import app.revanced.patches.all.misc.transformation.filterMapInstruction35c -import app.revanced.patches.all.misc.transformation.transformInstructionsPatch -import org.w3c.dom.Element - -private val removeCaptureRestrictionResourcePatch = resourcePatch( - description = "Sets allowAudioPlaybackCapture in manifest to true.", -) { - execute { - document("AndroidManifest.xml").use { document -> - // Get the application node. - val applicationNode = - document - .getElementsByTagName("application") - .item(0) as Element - - // Set allowAudioPlaybackCapture attribute to true. - applicationNode.setAttribute("android:allowAudioPlaybackCapture", "true") - } - } -} - -private const val EXTENSION_CLASS_DESCRIPTOR_PREFIX = - "Lapp/revanced/extension/all/screencapture/removerestriction/RemoveScreenCaptureRestrictionPatch" -private const val EXTENSION_CLASS_DESCRIPTOR = "$EXTENSION_CLASS_DESCRIPTOR_PREFIX;" - -@Suppress("unused") -val removeScreenCaptureRestrictionPatch = bytecodePatch( - name = "Remove screen capture restriction", - description = "Removes the restriction of capturing audio from apps that normally wouldn't allow it.", - use = false, -) { - extendWith("extensions/all/misc/screencapture/remove-screen-capture-restriction.rve") - - dependsOn( - removeCaptureRestrictionResourcePatch, - transformInstructionsPatch( - filterMap = { classDef, _, instruction, instructionIndex -> - filterMapInstruction35c( - EXTENSION_CLASS_DESCRIPTOR_PREFIX, - classDef, - instruction, - instructionIndex, - ) - }, - transform = { mutableMethod, entry -> - val (methodType, instruction, instructionIndex) = entry - methodType.replaceInvokeVirtualWithExtension( - EXTENSION_CLASS_DESCRIPTOR, - mutableMethod, - instruction, - instructionIndex, - ) - }, - ), - ) -} - -// Information about method calls we want to replace -@Suppress("unused") -private enum class MethodCall( - override val definedClassName: String, - override val methodName: String, - override val methodParams: Array, - override val returnType: String, -) : IMethodCall { - SetAllowedCapturePolicySingle( - "Landroid/media/AudioAttributes\$Builder;", - "setAllowedCapturePolicy", - arrayOf("I"), - "Landroid/media/AudioAttributes\$Builder;", - ), - SetAllowedCapturePolicyGlobal( - "Landroid/media/AudioManager;", - "setAllowedCapturePolicy", - arrayOf("I"), - "V", - ), -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/screenshot/RemoveScreenshotRestrictionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/screenshot/RemoveScreenshotRestrictionPatch.kt deleted file mode 100644 index 19c4ba0..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/screenshot/RemoveScreenshotRestrictionPatch.kt +++ /dev/null @@ -1,97 +0,0 @@ -package app.revanced.patches.all.misc.screenshot - -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.all.misc.transformation.IMethodCall -import app.revanced.patches.all.misc.transformation.filterMapInstruction35c -import app.revanced.patches.all.misc.transformation.transformInstructionsPatch -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction22c -import com.android.tools.smali.dexlib2.iface.reference.FieldReference - -private const val EXTENSION_CLASS_DESCRIPTOR_PREFIX = - "Lapp/revanced/extension/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch" -private const val EXTENSION_CLASS_DESCRIPTOR = "$EXTENSION_CLASS_DESCRIPTOR_PREFIX;" - -@Suppress("unused") -val removeScreenshotRestrictionPatch = bytecodePatch( - name = "Remove screenshot restriction", - description = "Removes the restriction of taking screenshots in apps that normally wouldn't allow it.", - use = false, -) { - extendWith("extensions/all/misc/screenshot/remove-screenshot-restriction.rve") - - dependsOn( - // Remove the restriction of taking screenshots. - transformInstructionsPatch( - filterMap = { classDef, _, instruction, instructionIndex -> - filterMapInstruction35c( - EXTENSION_CLASS_DESCRIPTOR_PREFIX, - classDef, - instruction, - instructionIndex, - ) - }, - transform = { mutableMethod, entry -> - val (methodType, instruction, instructionIndex) = entry - methodType.replaceInvokeVirtualWithExtension( - EXTENSION_CLASS_DESCRIPTOR, - mutableMethod, - instruction, - instructionIndex, - ) - }, - ), - // Modify layout params. - transformInstructionsPatch( - filterMap = { _, _, instruction, instructionIndex -> - if (instruction.opcode != Opcode.IPUT) { - return@transformInstructionsPatch null - } - - val instruction22c = instruction as Instruction22c - val fieldReference = instruction22c.reference as FieldReference - - if (fieldReference.definingClass != "Landroid/view/WindowManager\$LayoutParams;" || - fieldReference.name != "flags" || - fieldReference.type != "I" - ) { - return@transformInstructionsPatch null - } - - Pair(instruction22c, instructionIndex) - }, - transform = { mutableMethod, entry -> - val (instruction, index) = entry - val register = instruction.registerA - - mutableMethod.addInstructions( - index, - "and-int/lit16 v$register, v$register, -0x2001", - ) - }, - ), - ) -} - -// Information about method calls we want to replace -@Suppress("unused") -private enum class MethodCall( - override val definedClassName: String, - override val methodName: String, - override val methodParams: Array, - override val returnType: String, -) : IMethodCall { - AddFlags( - "Landroid/view/Window;", - "addFlags", - arrayOf("I"), - "V", - ), - SetFlags( - "Landroid/view/Window;", - "setFlags", - arrayOf("I", "I"), - "V", - ), -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/shortcut/sharetargets/RemoveShareTargetsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/shortcut/sharetargets/RemoveShareTargetsPatch.kt deleted file mode 100644 index 6b07c7d..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/shortcut/sharetargets/RemoveShareTargetsPatch.kt +++ /dev/null @@ -1,29 +0,0 @@ -package app.revanced.patches.all.misc.shortcut.sharetargets - -import app.revanced.patcher.patch.resourcePatch -import app.revanced.util.asSequence -import app.revanced.util.getNode -import org.w3c.dom.Element -import java.io.FileNotFoundException -import java.util.logging.Logger - -@Suppress("unused") -val removeShareTargetsPatch = resourcePatch( - name = "Remove share targets", - description = "Removes share targets like directly sharing to a frequent contact.", - use = false, -) { - execute { - try { - document("res/xml/shortcuts.xml") - } catch (_: FileNotFoundException) { - return@execute Logger.getLogger(this::class.java.name).warning("The app has no shortcuts") - }.use { document -> - val rootNode = document.getNode("shortcuts") as? Element ?: return@use - - document.getElementsByTagName("share-target").asSequence().forEach { - rootNode.removeChild(it) - } - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/targetSdk/SetTargetSdkVersion34.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/targetSdk/SetTargetSdkVersion34.kt deleted file mode 100644 index c79654d..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/targetSdk/SetTargetSdkVersion34.kt +++ /dev/null @@ -1,48 +0,0 @@ -package app.revanced.patches.all.misc.targetSdk - -import app.revanced.patcher.patch.resourcePatch -import app.revanced.util.getNode -import org.w3c.dom.Element -import java.util.logging.Logger - -@Suppress("unused") -val setTargetSdkVersion34 = resourcePatch( - name = "Set target SDK version 34", - description = "Changes the target SDK to version 34 (Android 14). " + - "For devices running Android 15+, this will disable edge-to-edge display.", - use = false, -) { - execute { - val targetSdkOverride = 34 // Android 14. - - document("AndroidManifest.xml").use { document -> - fun getLogger() = Logger.getLogger(this::class.java.name) - - // Ideally, the override should only be applied if the existing target is higher. - // But since ApkTool does not add targetSdkVersion to the decompiled AndroidManifest, - // there is no way to check targetSdkVersion. Instead, check compileSdkVersion and print a warning. - try { - val manifestElement = document.getNode("manifest") as Element - val compileSdkVersion = Integer.parseInt( - manifestElement.getAttribute("android:compileSdkVersion") - ) - if (compileSdkVersion <= targetSdkOverride) { - getLogger().warning( - "This app does not appear to use a target SDK above $targetSdkOverride: " + - "(compileSdkVersion: $compileSdkVersion)" - ) - } - } catch (_: Exception) { - getLogger().warning("Could not check compileSdkVersion") - } - - // Change targetSdkVersion to override value. - document.getElementsByTagName("manifest").item(0).let { - var element = it.ownerDocument.createElement("uses-sdk") - element.setAttribute("android:targetSdkVersion", targetSdkOverride.toString()) - - it.appendChild(element) - } - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/MethodCall.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/MethodCall.kt deleted file mode 100644 index 0c39436..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/MethodCall.kt +++ /dev/null @@ -1,95 +0,0 @@ -package app.revanced.patches.all.misc.transformation - -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction -import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.ClassDef -import com.android.tools.smali.dexlib2.iface.instruction.Instruction -import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c -import com.android.tools.smali.dexlib2.iface.reference.MethodReference - -typealias Instruction35cInfo = Triple - -interface IMethodCall { - val definedClassName: String - val methodName: String - val methodParams: Array - val returnType: String - - /** - * Replaces an invoke-virtual instruction with an invoke-static instruction, - * which calls a static replacement method in the respective extension class. - * The method definition in the extension class is expected to be the same, - * except that the method should be static and take as a first parameter - * an instance of the class, in which the original method was defined in. - * - * Example: - * - * original method: Window#setFlags(int, int) - * - * replacement method: Extension#setFlags(Window, int, int) - */ - fun replaceInvokeVirtualWithExtension( - definingClassDescriptor: String, - method: MutableMethod, - instruction: Instruction35c, - instructionIndex: Int, - ) { - val registers = arrayOf( - instruction.registerC, - instruction.registerD, - instruction.registerE, - instruction.registerF, - instruction.registerG, - ) - val argsNum = methodParams.size + 1 // + 1 for instance of definedClassName - if (argsNum > registers.size) { - // should never happen, but just to be sure (also for the future) a safety check - throw RuntimeException( - "Not enough registers for $definedClassName#$methodName: " + - "Required $argsNum registers, but only got ${registers.size}.", - ) - } - - val args = registers.take(argsNum).joinToString(separator = ", ") { reg -> "v$reg" } - val replacementMethod = - "$methodName(${definedClassName}${methodParams.joinToString(separator = "")})$returnType" - - method.replaceInstruction( - instructionIndex, - "invoke-static { $args }, $definingClassDescriptor->$replacementMethod", - ) - } -} - -inline fun fromMethodReference( - methodReference: MethodReference, -) - where E : Enum, E : IMethodCall = enumValues().firstOrNull { search -> - search.definedClassName == methodReference.definingClass && - search.methodName == methodReference.name && - methodReference.parameterTypes.toTypedArray().contentEquals(search.methodParams) && - search.returnType == methodReference.returnType -} - -inline fun filterMapInstruction35c( - extensionClassDescriptorPrefix: String, - classDef: ClassDef, - instruction: Instruction, - instructionIndex: Int, -): Instruction35cInfo? where E : Enum, E : IMethodCall { - if (classDef.startsWith(extensionClassDescriptorPrefix)) { - // avoid infinite recursion - return null - } - - if (instruction.opcode != Opcode.INVOKE_VIRTUAL) { - return null - } - - val invokeInstruction = instruction as Instruction35c - val methodRef = invokeInstruction.reference as MethodReference - val methodCall = fromMethodReference(methodRef) ?: return null - - return Instruction35cInfo(methodCall, invokeInstruction, instructionIndex) -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/TransformInstructionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/TransformInstructionsPatch.kt deleted file mode 100644 index 6564f4f..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/TransformInstructionsPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.all.misc.transformation - -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.util.findMutableMethodOf -import com.android.tools.smali.dexlib2.iface.ClassDef -import com.android.tools.smali.dexlib2.iface.Method -import com.android.tools.smali.dexlib2.iface.instruction.Instruction - -fun transformInstructionsPatch( - filterMap: (ClassDef, Method, Instruction, Int) -> T?, - transform: (MutableMethod, T) -> Unit, -) = bytecodePatch { - // Returns the patch indices as a Sequence, which will execute lazily. - fun findPatchIndices(classDef: ClassDef, method: Method): Sequence? = - method.implementation?.instructions?.asSequence()?.withIndex()?.mapNotNull { (index, instruction) -> - filterMap(classDef, method, instruction, index) - } - - execute { - // Find all methods to patch - buildMap { - classes.forEach { classDef -> - val methods = buildList { - classDef.methods.forEach { method -> - // Since the Sequence executes lazily, - // using any() results in only calling - // filterMap until the first index has been found. - if (findPatchIndices(classDef, method)?.any() == true) add(method) - } - } - - if (methods.isNotEmpty()) { - put(classDef, methods) - } - } - }.forEach { (classDef, methods) -> - // And finally transform the methods... - val mutableClass = proxy(classDef).mutableClass - - methods.map(mutableClass::findMutableMethodOf).forEach methods@{ mutableMethod -> - val patchIndices = findPatchIndices(mutableClass, mutableMethod)?.toCollection(ArrayDeque()) - ?: return@methods - - while (!patchIndices.isEmpty()) transform(mutableMethod, patchIndices.removeLast()) - } - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/versioncode/ChangeVersionCodePatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/versioncode/ChangeVersionCodePatch.kt deleted file mode 100644 index a50fe58..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/versioncode/ChangeVersionCodePatch.kt +++ /dev/null @@ -1,34 +0,0 @@ -package app.revanced.patches.all.misc.versioncode - -import app.revanced.patcher.patch.intOption -import app.revanced.patcher.patch.resourcePatch -import app.revanced.util.getNode -import org.w3c.dom.Element - -@Suppress("unused") -val changeVersionCodePatch = resourcePatch( - name = "Change version code", - description = "Changes the version code of the app. This will turn off app store updates " + - "and allows downgrading an existing app install to an older app version.", - use = false, -) { - val versionCode by intOption( - key = "versionCode", - default = Int.MAX_VALUE, - values = mapOf( - "Lowest" to 1, - "Highest" to Int.MAX_VALUE, - ), - title = "Version code", - description = "The version code to use. Using the highest value turns off app store " + - "updates and allows downgrading an existing app install to an older app version.", - required = true, - ) { versionCode -> versionCode!! >= 1 } - - execute { - document("AndroidManifest.xml").use { document -> - val manifestElement = document.getNode("manifest") as Element - manifestElement.setAttribute("android:versionCode", "$versionCode") - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/Fingerprints.kt deleted file mode 100644 index 80d041a..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/Fingerprints.kt +++ /dev/null @@ -1,18 +0,0 @@ -package app.revanced.patches.shared.misc.fix.verticalscroll - -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.AccessFlags -import app.revanced.patcher.fingerprint - -internal val canScrollVerticallyFingerprint = fingerprint { - accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) - returns("Z") - parameters() - opcodes( - Opcode.MOVE_RESULT, - Opcode.RETURN, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT - ) - custom { _, classDef -> classDef.endsWith("SwipeRefreshLayout;") } -} \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch.kt deleted file mode 100644 index a01839c..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch.kt +++ /dev/null @@ -1,24 +0,0 @@ -package app.revanced.patches.shared.misc.fix.verticalscroll - -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.patch.bytecodePatch -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction - -val verticalScrollPatch = bytecodePatch( - description = "Fixes issues with refreshing the feed when the first component is of type EmptyComponent.", -) { - - execute { - canScrollVerticallyFingerprint.method.apply { - val moveResultIndex = canScrollVerticallyFingerprint.patternMatch!!.endIndex - val moveResultRegister = getInstruction(moveResultIndex).registerA - - val insertIndex = moveResultIndex + 1 - addInstruction( - insertIndex, - "const/4 v$moveResultRegister, 0x0", - ) - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/Fingerprints.kt deleted file mode 100644 index b5f613d..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/Fingerprints.kt +++ /dev/null @@ -1,30 +0,0 @@ -package app.revanced.patches.shared.misc.gms - -import app.revanced.patcher.fingerprint -import com.android.tools.smali.dexlib2.AccessFlags - -const val GET_GMS_CORE_VENDOR_GROUP_ID_METHOD_NAME = "getGmsCoreVendorGroupId" - -internal val gmsCoreSupportFingerprint = fingerprint { - custom { _, classDef -> - classDef.endsWith("GmsCoreSupport;") - } -} - -internal val googlePlayUtilityFingerprint = fingerprint { - accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) - returns("I") - parameters("L", "I") - strings( - "This should never happen.", - "MetadataValueReader", - "com.google.android.gms", - ) -} - -internal val serviceCheckFingerprint = fingerprint { - accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) - returns("V") - parameters("L", "I") - strings("Google Play Services not available") -} diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/GmsCoreSupportPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/GmsCoreSupportPatch.kt deleted file mode 100644 index 694d471..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/GmsCoreSupportPatch.kt +++ /dev/null @@ -1,628 +0,0 @@ -package app.revanced.patches.shared.misc.gms - -import app.revanced.patcher.Fingerprint -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -import app.revanced.patcher.extensions.InstructionExtensions.instructions -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction -import app.revanced.patcher.patch.* -import app.revanced.patches.all.misc.packagename.changePackageNamePatch -import app.revanced.patches.all.misc.packagename.setOrGetFallbackPackageName -import app.revanced.patches.all.misc.resources.addResources -import app.revanced.patches.all.misc.resources.addResourcesPatch -import app.revanced.patches.shared.misc.gms.Constants.ACTIONS -import app.revanced.patches.shared.misc.gms.Constants.AUTHORITIES -import app.revanced.patches.shared.misc.gms.Constants.PERMISSIONS -import app.revanced.util.* -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction21c -import com.android.tools.smali.dexlib2.iface.reference.StringReference -import com.android.tools.smali.dexlib2.immutable.reference.ImmutableStringReference -import com.android.tools.smali.dexlib2.util.MethodUtil -import org.w3c.dom.Element -import org.w3c.dom.Node - -private const val PACKAGE_NAME_REGEX_PATTERN = "^[a-z]\\w*(\\.[a-z]\\w*)+\$" - -/** - * A patch that allows patched Google apps to run without root and under a different package name - * by using GmsCore instead of Google Play Services. - * - * @param fromPackageName The package name of the original app. - * @param toPackageName The package name to fall back to if no custom package name is specified in patch options. - * @param primeMethodFingerprint The fingerprint of the "prime" method that needs to be patched. - * @param earlyReturnFingerprints The fingerprints of methods that need to be returned early. - * @param mainActivityOnCreateFingerprint The fingerprint of the main activity onCreate method. - * @param extensionPatch The patch responsible for the extension. - * @param gmsCoreSupportResourcePatchFactory The factory for the corresponding resource patch - * that is used to patch the resources. - * @param executeBlock The additional execution block of the patch. - * @param block The additional block to build the patch. - */ -fun gmsCoreSupportPatch( - fromPackageName: String, - toPackageName: String, - primeMethodFingerprint: Fingerprint? = null, - earlyReturnFingerprints: Set = setOf(), - mainActivityOnCreateFingerprint: Fingerprint, - extensionPatch: Patch<*>, - gmsCoreSupportResourcePatchFactory: (gmsCoreVendorGroupIdOption: Option) -> Patch<*>, - executeBlock: BytecodePatchContext.() -> Unit = {}, - block: BytecodePatchBuilder.() -> Unit = {}, -) = bytecodePatch( - name = "GmsCore support", - description = "Allows patched Google apps to run without root and under a different package name " + - "by using GmsCore instead of Google Play Services.", -) { - val gmsCoreVendorGroupIdOption = stringOption( - key = "gmsCoreVendorGroupId", - default = "app.revanced", - values = - mapOf( - "ReVanced" to "app.revanced", - ), - title = "GmsCore vendor group ID", - description = "The vendor's group ID for GmsCore.", - required = true, - ) { it!!.matches(Regex(PACKAGE_NAME_REGEX_PATTERN)) } - - dependsOn( - changePackageNamePatch, - gmsCoreSupportResourcePatchFactory(gmsCoreVendorGroupIdOption), - extensionPatch, - ) - - val gmsCoreVendorGroupId by gmsCoreVendorGroupIdOption - - execute { - fun transformStringReferences(transform: (str: String) -> String?) = classes.forEach { - val mutableClass by lazy { - proxy(it).mutableClass - } - - it.methods.forEach classLoop@{ method -> - val implementation = method.implementation ?: return@classLoop - - val mutableMethod by lazy { - mutableClass.methods.first { MethodUtil.methodSignaturesMatch(it, method) } - } - - implementation.instructions.forEachIndexed insnLoop@{ index, instruction -> - val string = ((instruction as? Instruction21c)?.reference as? StringReference)?.string - ?: return@insnLoop - - // Apply transformation. - val transformedString = transform(string) ?: return@insnLoop - - mutableMethod.replaceInstruction( - index, - BuilderInstruction21c( - Opcode.CONST_STRING, - instruction.registerA, - ImmutableStringReference(transformedString), - ), - ) - } - } - } - - // region Collection of transformations that are applied to all strings. - - fun commonTransform(referencedString: String): String? = when (referencedString) { - "com.google", - "com.google.android.gms", - in PERMISSIONS, - in ACTIONS, - in AUTHORITIES, - -> referencedString.replace("com.google", gmsCoreVendorGroupId!!) - - // No vendor prefix for whatever reason... - "subscribedfeeds" -> "$gmsCoreVendorGroupId.subscribedfeeds" - else -> null - } - - fun contentUrisTransform(str: String): String? { - // only when content:// uri - if (str.startsWith("content://")) { - // check if matches any authority - for (authority in AUTHORITIES) { - val uriPrefix = "content://$authority" - if (str.startsWith(uriPrefix)) { - return str.replace( - uriPrefix, - "content://${authority.replace("com.google", gmsCoreVendorGroupId!!)}", - ) - } - } - - // gms also has a 'subscribedfeeds' authority, check for that one too - val subFeedsUriPrefix = "content://subscribedfeeds" - if (str.startsWith(subFeedsUriPrefix)) { - return str.replace(subFeedsUriPrefix, "content://$gmsCoreVendorGroupId.subscribedfeeds") - } - } - - return null - } - - fun packageNameTransform(fromPackageName: String, toPackageName: String): (String) -> String? = { string -> - when (string) { - "$fromPackageName.SuggestionsProvider", - "$fromPackageName.fileprovider", - -> string.replace(fromPackageName, toPackageName) - - else -> null - } - } - - fun transformPrimeMethod(packageName: String) { - primeMethodFingerprint!!.method.apply { - var register = 2 - - val index = instructions.indexOfFirst { - if (it.getReference()?.string != fromPackageName) return@indexOfFirst false - - register = (it as OneRegisterInstruction).registerA - return@indexOfFirst true - } - - replaceInstruction(index, "const-string v$register, \"$packageName\"") - } - } - - // endregion - - val packageName = setOrGetFallbackPackageName(toPackageName) - - // Transform all strings using all provided transforms, first match wins. - val transformations = arrayOf( - ::commonTransform, - ::contentUrisTransform, - packageNameTransform(fromPackageName, packageName), - ) - transformStringReferences transform@{ string -> - transformations.forEach { transform -> - transform(string)?.let { transformedString -> return@transform transformedString } - } - - return@transform null - } - - // Specific method that needs to be patched. - primeMethodFingerprint?.let { transformPrimeMethod(packageName) } - - // Return these methods early to prevent the app from crashing. - earlyReturnFingerprints.forEach { it.method.returnEarly() } - serviceCheckFingerprint.method.returnEarly() - - // Google Play Utility is not present in all apps, so we need to check if it's present. - if (googlePlayUtilityFingerprint.methodOrNull != null) { - googlePlayUtilityFingerprint.method.returnEarly() - } - - // Verify GmsCore is installed and whitelisted for power optimizations and background usage. - mainActivityOnCreateFingerprint.method.apply { - addInstructions( - 0, - "invoke-static/range { p0 .. p0 }, Lapp/revanced/extension/shared/GmsCoreSupport;->" + - "checkGmsCore(Landroid/app/Activity;)V", - ) - } - - // Change the vendor of GmsCore in the extension. - gmsCoreSupportFingerprint.classDef.methods - .single { it.name == GET_GMS_CORE_VENDOR_GROUP_ID_METHOD_NAME } - .replaceInstruction(0, "const-string v0, \"$gmsCoreVendorGroupId\"") - - executeBlock() - } - - block() -} - -/** - * A collection of permissions, intents and content provider authorities - * that are present in GmsCore which need to be transformed. - */ -private object Constants { - /** - * All permissions. - */ - val PERMISSIONS = setOf( - "com.google.android.c2dm.permission.RECEIVE", - "com.google.android.c2dm.permission.SEND", - "com.google.android.gms.auth.api.phone.permission.SEND", - "com.google.android.gms.permission.AD_ID", - "com.google.android.gms.permission.AD_ID_NOTIFICATION", - "com.google.android.gms.permission.CAR_FUEL", - "com.google.android.gms.permission.CAR_INFORMATION", - "com.google.android.gms.permission.CAR_MILEAGE", - "com.google.android.gms.permission.CAR_SPEED", - "com.google.android.gms.permission.CAR_VENDOR_EXTENSION", - "com.google.android.googleapps.permission.GOOGLE_AUTH", - "com.google.android.googleapps.permission.GOOGLE_AUTH.cp", - "com.google.android.googleapps.permission.GOOGLE_AUTH.local", - "com.google.android.googleapps.permission.GOOGLE_AUTH.mail", - "com.google.android.googleapps.permission.GOOGLE_AUTH.writely", - "com.google.android.gtalkservice.permission.GTALK_SERVICE", - "com.google.android.providers.gsf.permission.READ_GSERVICES", - ) - - /** - * All intent actions. - */ - val ACTIONS = setOf( - "com.google.android.c2dm.intent.RECEIVE", - "com.google.android.c2dm.intent.REGISTER", - "com.google.android.c2dm.intent.REGISTRATION", - "com.google.android.c2dm.intent.UNREGISTER", - "com.google.android.contextmanager.service.ContextManagerService.START", - "com.google.android.gcm.intent.SEND", - "com.google.android.gms.accounts.ACCOUNT_SERVICE", - "com.google.android.gms.accountsettings.ACCOUNT_PREFERENCES_SETTINGS", - "com.google.android.gms.accountsettings.action.BROWSE_SETTINGS", - "com.google.android.gms.accountsettings.action.VIEW_SETTINGS", - "com.google.android.gms.accountsettings.MY_ACCOUNT", - "com.google.android.gms.accountsettings.PRIVACY_SETTINGS", - "com.google.android.gms.accountsettings.SECURITY_SETTINGS", - "com.google.android.gms.ads.gservice.START", - "com.google.android.gms.ads.identifier.service.EVENT_ATTESTATION", - "com.google.android.gms.ads.service.CACHE", - "com.google.android.gms.ads.service.CONSENT_LOOKUP", - "com.google.android.gms.ads.service.HTTP", - "com.google.android.gms.analytics.service.START", - "com.google.android.gms.app.settings.GoogleSettingsLink", - "com.google.android.gms.appstate.service.START", - "com.google.android.gms.appusage.service.START", - "com.google.android.gms.asterism.service.START", - "com.google.android.gms.audiomodem.service.AudioModemService.START", - "com.google.android.gms.audit.service.START", - "com.google.android.gms.auth.account.authapi.START", - "com.google.android.gms.auth.account.authenticator.auto.service.START", - "com.google.android.gms.auth.account.authenticator.chromeos.START", - "com.google.android.gms.auth.account.authenticator.tv.service.START", - "com.google.android.gms.auth.account.data.service.START", - "com.google.android.gms.auth.api.credentials.PICKER", - "com.google.android.gms.auth.api.credentials.service.START", - "com.google.android.gms.auth.api.identity.service.authorization.START", - "com.google.android.gms.auth.api.identity.service.credentialsaving.START", - "com.google.android.gms.auth.api.identity.service.signin.START", - "com.google.android.gms.auth.api.phone.service.InternalService.START", - "com.google.android.gms.auth.api.signin.service.START", - "com.google.android.gms.auth.be.appcert.AppCertService", - "com.google.android.gms.auth.blockstore.service.START", - "com.google.android.gms.auth.config.service.START", - "com.google.android.gms.auth.cryptauth.cryptauthservice.START", - "com.google.android.gms.auth.GOOGLE_SIGN_IN", - "com.google.android.gms.auth.login.LOGIN", - "com.google.android.gms.auth.proximity.devicesyncservice.START", - "com.google.android.gms.auth.proximity.securechannelservice.START", - "com.google.android.gms.auth.proximity.START", - "com.google.android.gms.auth.service.START", - "com.google.android.gms.backup.ACTION_BACKUP_SETTINGS", - "com.google.android.gms.backup.G1_BACKUP", - "com.google.android.gms.backup.G1_RESTORE", - "com.google.android.gms.backup.GMS_MODULE_RESTORE", - "com.google.android.gms.beacon.internal.IBleService.START", - "com.google.android.gms.car.service.START", - "com.google.android.gms.carrierauth.service.START", - "com.google.android.gms.cast.firstparty.START", - "com.google.android.gms.cast.remote_display.service.START", - "com.google.android.gms.cast.service.BIND_CAST_DEVICE_CONTROLLER_SERVICE", - "com.google.android.gms.cast_mirroring.service.START", - "com.google.android.gms.checkin.BIND_TO_SERVICE", - "com.google.android.gms.chromesync.service.START", - "com.google.android.gms.clearcut.service.START", - "com.google.android.gms.common.account.CHOOSE_ACCOUNT", - "com.google.android.gms.common.download.START", - "com.google.android.gms.common.service.START", - "com.google.android.gms.common.telemetry.service.START", - "com.google.android.gms.config.START", - "com.google.android.gms.constellation.service.START", - "com.google.android.gms.credential.manager.service.firstparty.START", - "com.google.android.gms.deviceconnection.service.START", - "com.google.android.gms.drive.ApiService.RESET_AFTER_BOOT", - "com.google.android.gms.drive.ApiService.START", - "com.google.android.gms.drive.ApiService.STOP", - "com.google.android.gms.droidguard.service.INIT", - "com.google.android.gms.droidguard.service.PING", - "com.google.android.gms.droidguard.service.START", - "com.google.android.gms.enterprise.loader.service.START", - "com.google.android.gms.facs.cache.service.START", - "com.google.android.gms.facs.internal.service.START", - "com.google.android.gms.feedback.internal.IFeedbackService", - "com.google.android.gms.fido.credentialstore.internal_service.START", - "com.google.android.gms.fido.fido2.privileged.START", - "com.google.android.gms.fido.fido2.regular.START", - "com.google.android.gms.fido.fido2.zeroparty.START", - "com.google.android.gms.fido.sourcedevice.service.START", - "com.google.android.gms.fido.targetdevice.internal_service.START", - "com.google.android.gms.fido.u2f.privileged.START", - "com.google.android.gms.fido.u2f.thirdparty.START", - "com.google.android.gms.fido.u2f.zeroparty.START", - "com.google.android.gms.fitness.BleApi", - "com.google.android.gms.fitness.ConfigApi", - "com.google.android.gms.fitness.GoalsApi", - "com.google.android.gms.fitness.GoogleFitnessService.START", - "com.google.android.gms.fitness.HistoryApi", - "com.google.android.gms.fitness.InternalApi", - "com.google.android.gms.fitness.RecordingApi", - "com.google.android.gms.fitness.SensorsApi", - "com.google.android.gms.fitness.SessionsApi", - "com.google.android.gms.fonts.service.START", - "com.google.android.gms.freighter.service.START", - "com.google.android.gms.games.internal.connect.service.START", - "com.google.android.gms.games.PLAY_GAMES_UPGRADE", - "com.google.android.gms.games.service.START", - "com.google.android.gms.gass.START", - "com.google.android.gms.gmscompliance.service.START", - "com.google.android.gms.googlehelp.HELP", - "com.google.android.gms.googlehelp.service.GoogleHelpService.START", - "com.google.android.gms.growth.service.START", - "com.google.android.gms.herrevad.services.LightweightNetworkQualityAndroidService.START", - "com.google.android.gms.icing.INDEX_SERVICE", - "com.google.android.gms.icing.LIGHTWEIGHT_INDEX_SERVICE", - "com.google.android.gms.identity.service.BIND", - "com.google.android.gms.inappreach.service.START", - "com.google.android.gms.instantapps.START", - "com.google.android.gms.kids.service.START", - "com.google.android.gms.languageprofile.service.START", - "com.google.android.gms.learning.internal.dynamitesupport.START", - "com.google.android.gms.learning.intservice.START", - "com.google.android.gms.learning.predictor.START", - "com.google.android.gms.learning.trainer.START", - "com.google.android.gms.learning.training.background.START", - "com.google.android.gms.location.places.GeoDataApi", - "com.google.android.gms.location.places.PlaceDetectionApi", - "com.google.android.gms.location.places.PlacesApi", - "com.google.android.gms.location.reporting.service.START", - "com.google.android.gms.location.settings.LOCATION_HISTORY", - "com.google.android.gms.location.settings.LOCATION_REPORTING_SETTINGS", - "com.google.android.gms.locationsharing.api.START", - "com.google.android.gms.locationsharingreporter.service.START", - "com.google.android.gms.lockbox.service.START", - "com.google.android.gms.matchstick.lighter.service.START", - "com.google.android.gms.mdm.services.DeviceManagerApiService.START", - "com.google.android.gms.mdm.services.START", - "com.google.android.gms.mdns.service.START", - "com.google.android.gms.measurement.START", - "com.google.android.gms.nearby.bootstrap.service.NearbyBootstrapService.START", - "com.google.android.gms.nearby.connection.service.START", - "com.google.android.gms.nearby.fastpair.START", - "com.google.android.gms.nearby.messages.service.NearbyMessagesService.START", - "com.google.android.gms.nearby.sharing.service.NearbySharingService.START", - "com.google.android.gms.nearby.sharing.START_SERVICE", - "com.google.android.gms.notifications.service.START", - "com.google.android.gms.ocr.service.internal.START", - "com.google.android.gms.ocr.service.START", - "com.google.android.gms.oss.licenses.service.START", - "com.google.android.gms.payse.service.BIND", - "com.google.android.gms.people.contactssync.service.START", - "com.google.android.gms.people.service.START", - "com.google.android.gms.phenotype.service.START", - "com.google.android.gms.photos.autobackup.service.START", - "com.google.android.gms.playlog.service.START", - "com.google.android.gms.plus.service.default.INTENT", - "com.google.android.gms.plus.service.image.INTENT", - "com.google.android.gms.plus.service.internal.START", - "com.google.android.gms.plus.service.START", - "com.google.android.gms.potokens.service.START", - "com.google.android.gms.pseudonymous.service.START", - "com.google.android.gms.rcs.START", - "com.google.android.gms.reminders.service.START", - "com.google.android.gms.romanesco.MODULE_BACKUP_AGENT", - "com.google.android.gms.romanesco.service.START", - "com.google.android.gms.safetynet.service.START", - "com.google.android.gms.scheduler.ACTION_PROXY_SCHEDULE", - "com.google.android.gms.search.service.SEARCH_AUTH_START", - "com.google.android.gms.semanticlocation.service.START_ODLH", - "com.google.android.gms.sesame.service.BIND", - "com.google.android.gms.settings.EXPOSURE_NOTIFICATION_SETTINGS", - "com.google.android.gms.setup.auth.SecondDeviceAuth.START", - "com.google.android.gms.signin.service.START", - "com.google.android.gms.smartdevice.d2d.SourceDeviceService.START", - "com.google.android.gms.smartdevice.d2d.TargetDeviceService.START", - "com.google.android.gms.smartdevice.directtransfer.SourceDirectTransferService.START", - "com.google.android.gms.smartdevice.directtransfer.TargetDirectTransferService.START", - "com.google.android.gms.smartdevice.postsetup.PostSetupService.START", - "com.google.android.gms.smartdevice.setup.accounts.AccountsService.START", - "com.google.android.gms.smartdevice.wifi.START_WIFI_HELPER_SERVICE", - "com.google.android.gms.social.location.activity.service.START", - "com.google.android.gms.speech.service.START", - "com.google.android.gms.statementservice.EXECUTE", - "com.google.android.gms.stats.ACTION_UPLOAD_DROPBOX_ENTRIES", - "com.google.android.gms.tapandpay.service.BIND", - "com.google.android.gms.telephonyspam.service.START", - "com.google.android.gms.testsupport.service.START", - "com.google.android.gms.thunderbird.service.START", - "com.google.android.gms.trustagent.BridgeApi.START", - "com.google.android.gms.trustagent.StateApi.START", - "com.google.android.gms.trustagent.trustlet.trustletmanagerservice.BIND", - "com.google.android.gms.trustlet.bluetooth.service.BIND", - "com.google.android.gms.trustlet.connectionlessble.service.BIND", - "com.google.android.gms.trustlet.face.service.BIND", - "com.google.android.gms.trustlet.nfc.service.BIND", - "com.google.android.gms.trustlet.onbody.service.BIND", - "com.google.android.gms.trustlet.place.service.BIND", - "com.google.android.gms.trustlet.voiceunlock.service.BIND", - "com.google.android.gms.udc.service.START", - "com.google.android.gms.update.START_API_SERVICE", - "com.google.android.gms.update.START_SERVICE", - "com.google.android.gms.update.START_SINGLE_USER_API_SERVICE", - "com.google.android.gms.update.START_TV_API_SERVICE", - "com.google.android.gms.usagereporting.service.START", - "com.google.android.gms.userlocation.service.START", - "com.google.android.gms.vehicle.cabin.service.START", - "com.google.android.gms.vehicle.climate.service.START", - "com.google.android.gms.vehicle.info.service.START", - "com.google.android.gms.wallet.service.BIND", - "com.google.android.gms.walletp2p.service.firstparty.BIND", - "com.google.android.gms.walletp2p.service.zeroparty.BIND", - "com.google.android.gms.wearable.BIND", - "com.google.android.gms.wearable.BIND_LISTENER", - "com.google.android.gms.wearable.DATA_CHANGED", - "com.google.android.gms.wearable.MESSAGE_RECEIVED", - "com.google.android.gms.wearable.NODE_CHANGED", - "com.google.android.gsf.action.GET_GLS", - "com.google.android.location.settings.LOCATION_REPORTING_SETTINGS", - "com.google.android.mdd.service.START", - "com.google.android.mdh.service.listener.START", - "com.google.android.mdh.service.START", - "com.google.android.mobstore.service.START", - "com.google.firebase.auth.api.gms.service.START", - "com.google.firebase.dynamiclinks.service.START", - "com.google.iid.TOKEN_REQUEST", - "com.google.android.gms.location.places.ui.PICK_PLACE", - ) - - /** - * All content provider authorities. - */ - val AUTHORITIES = setOf( - "com.google.android.gms.auth.accounts", - "com.google.android.gms.chimera", - "com.google.android.gms.fonts", - "com.google.android.gms.phenotype", - "com.google.android.gsf.gservices", - "com.google.settings", - ) -} - -/** - * Abstract resource patch that allows Google apps to run without root and under a different package name - * by using GmsCore instead of Google Play Services. - * - * @param fromPackageName The package name of the original app. - * @param toPackageName The package name to fall back to if no custom package name is specified in patch options. - * @param spoofedPackageSignature The signature of the package to spoof to. - * @param gmsCoreVendorGroupIdOption The option to get the vendor group ID of GmsCore. - * @param executeBlock The additional execution block of the patch. - * @param block The additional block to build the patch. - */ -fun gmsCoreSupportResourcePatch( // This is here only for binary compatibility. - fromPackageName: String, - toPackageName: String, - spoofedPackageSignature: String, - gmsCoreVendorGroupIdOption: Option, - executeBlock: ResourcePatchContext.() -> Unit = {}, - block: ResourcePatchBuilder.() -> Unit = {}, -) = gmsCoreSupportResourcePatch( - fromPackageName, - toPackageName, - spoofedPackageSignature, - gmsCoreVendorGroupIdOption, - true, - executeBlock, - block -) - -/** - * Abstract resource patch that allows Google apps to run without root and under a different package name - * by using GmsCore instead of Google Play Services. - * - * @param fromPackageName The package name of the original app. - * @param toPackageName The package name to fall back to if no custom package name is specified in patch options. - * @param spoofedPackageSignature The signature of the package to spoof to. - * @param gmsCoreVendorGroupIdOption The option to get the vendor group ID of GmsCore. - * @param addStringResources If the GmsCore shared strings should be added to the patched app. - * @param executeBlock The additional execution block of the patch. - * @param block The additional block to build the patch. - */ -// TODO: On the next major release make this public and delete the public overloaded constructor. -internal fun gmsCoreSupportResourcePatch( - fromPackageName: String, - toPackageName: String, - spoofedPackageSignature: String, - gmsCoreVendorGroupIdOption: Option, - addStringResources: Boolean = true, - executeBlock: ResourcePatchContext.() -> Unit = {}, - block: ResourcePatchBuilder.() -> Unit = {}, -) = resourcePatch { - dependsOn( - changePackageNamePatch, - addResourcesPatch, - ) - - val gmsCoreVendorGroupId by gmsCoreVendorGroupIdOption - - execute { - // Some patches don't use shared String resources so there's no need to add them. - if (addStringResources) { - addResources("shared", "misc.gms.gmsCoreSupportResourcePatch") - } - - /** - * Add metadata to manifest to support spoofing the package name and signature of GmsCore. - */ - fun addSpoofingMetadata() { - fun Node.adoptChild( - tagName: String, - block: Element.() -> Unit, - ) { - val child = ownerDocument.createElement(tagName) - child.block() - appendChild(child) - } - - document("AndroidManifest.xml").use { document -> - val applicationNode = - document - .getElementsByTagName("application") - .item(0) - - // Spoof package name and signature. - applicationNode.adoptChild("meta-data") { - setAttribute("android:name", "$gmsCoreVendorGroupId.android.gms.SPOOFED_PACKAGE_NAME") - setAttribute("android:value", fromPackageName) - } - - applicationNode.adoptChild("meta-data") { - setAttribute("android:name", "$gmsCoreVendorGroupId.android.gms.SPOOFED_PACKAGE_SIGNATURE") - setAttribute("android:value", spoofedPackageSignature) - } - - // GmsCore presence detection in extension. - applicationNode.adoptChild("meta-data") { - // TODO: The name of this metadata should be dynamic. - setAttribute("android:name", "app.revanced.MICROG_PACKAGE_NAME") - setAttribute("android:value", "$gmsCoreVendorGroupId.android.gms") - } - } - } - - /** - * Patch the manifest to support GmsCore. - */ - fun patchManifest() { - val packageName = setOrGetFallbackPackageName(toPackageName) - - val transformations = mapOf( - "package=\"$fromPackageName" to "package=\"$packageName", - "android:authorities=\"$fromPackageName" to "android:authorities=\"$packageName", - "$fromPackageName.permission.C2D_MESSAGE" to "$packageName.permission.C2D_MESSAGE", - "$fromPackageName.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION" to "$packageName.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION", - "com.google.android.c2dm" to "$gmsCoreVendorGroupId.android.c2dm", - "com.google.android.libraries.photos.api.mars" to "$gmsCoreVendorGroupId.android.apps.photos.api.mars", - "" to "", - ) - - val manifest = get("AndroidManifest.xml") - manifest.writeText( - transformations.entries.fold(manifest.readText()) { acc, (from, to) -> - acc.replace( - from, - to, - ) - }, - ) - } - - patchManifest() - addSpoofingMetadata() - - executeBlock() - } - - block() -} diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/SettingsPatch.kt deleted file mode 100644 index c8d8bd1..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/SettingsPatch.kt +++ /dev/null @@ -1,105 +0,0 @@ -package app.revanced.patches.shared.misc.settings - -import app.revanced.patcher.patch.PatchException -import app.revanced.patcher.patch.resourcePatch -import app.revanced.patches.all.misc.resources.addResource -import app.revanced.patches.all.misc.resources.addResources -import app.revanced.patches.all.misc.resources.addResourcesPatch -import app.revanced.patches.shared.misc.settings.preference.BasePreference -import app.revanced.patches.shared.misc.settings.preference.IntentPreference -import app.revanced.patches.shared.misc.settings.preference.PreferenceCategory -import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference -import app.revanced.util.ResourceGroup -import app.revanced.util.copyResources -import app.revanced.util.getNode -import app.revanced.util.insertFirst -import org.w3c.dom.Node - -// TODO: Delete this on next major version bump. -@Deprecated("Use non deprecated settings patch function") -fun settingsPatch ( - rootPreference: Pair, - preferences: Set, -) = settingsPatch(listOf(rootPreference), preferences) - -/** - * A resource patch that adds settings to a settings fragment. - * - * @param rootPreferences List of intent preferences and the name of the fragment file to add it to. - * File names that do not exist are ignored and not processed. - * @param preferences A set of preferences to add to the ReVanced fragment. - */ -fun settingsPatch ( - rootPreferences: List>? = null, - preferences: Set, -) = resourcePatch { - dependsOn(addResourcesPatch) - - execute { - copyResources( - "settings", - ResourceGroup("xml", "revanced_prefs.xml", "revanced_prefs_icons.xml"), - ) - - addResources("shared", "misc.settings.settingsResourcePatch") - } - - finalize { - fun Node.addPreference(preference: BasePreference) { - preference.serialize(ownerDocument) { resource -> - // TODO: Currently, resources can only be added to "values", which may not be the correct place. - // It may be necessary to ask for the desired resourceValue in the future. - addResource("values", resource) - }.let { preferenceNode -> - insertFirst(preferenceNode) - } - } - - // Add the root preference to an existing fragment if needed. - rootPreferences?.let { - var modified = false - - it.forEach { (intent, fileName) -> - val preferenceFileName = "res/xml/$fileName.xml" - if (get(preferenceFileName).exists()) { - document(preferenceFileName).use { document -> - document.getNode("PreferenceScreen").addPreference(intent) - } - modified = true - } - } - - if (!modified) throw PatchException("No declared preference files exists: $rootPreferences") - } - - // Add all preferences to the ReVanced fragment. - document("res/xml/revanced_prefs_icons.xml").use { document -> - val revancedPreferenceScreenNode = document.getNode("PreferenceScreen") - preferences.forEach { revancedPreferenceScreenNode.addPreference(it) } - } - - // Because the icon preferences require declaring a layout resource, - // there is no easy way to change to the Android default preference layout - // after the preference is inflated. - // Using two different preference files is the simplest and most robust solution. - fun removeIconsAndLayout(preferences: Collection) { - preferences.forEach { preference -> - preference.icon = null - preference.layout = null - - if (preference is PreferenceCategory) { - removeIconsAndLayout(preference.preferences) - } - if (preference is PreferenceScreenPreference) { - removeIconsAndLayout(preference.preferences) - } - } - } - removeIconsAndLayout(preferences) - - document("res/xml/revanced_prefs.xml").use { document -> - val revancedPreferenceScreenNode = document.getNode("PreferenceScreen") - preferences.forEach { revancedPreferenceScreenNode.addPreference(it) } - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreference.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreference.kt deleted file mode 100644 index 5428b39..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreference.kt +++ /dev/null @@ -1,78 +0,0 @@ -package app.revanced.patches.shared.misc.settings.preference - -import app.revanced.util.resource.BaseResource -import org.w3c.dom.Document -import org.w3c.dom.Element - -/** - * Base preference class for all preferences. - * - * @param key The key of the preference. If null, other parameters must be specified. - * @param titleKey The key of the preference title. - * @param icon The preference icon resource name. - * @param layout Layout declaration. - * @param summaryKey The key of the preference summary. - * @param tag The tag or full class name of the preference. - */ -@Suppress("MemberVisibilityCanBePrivate") -abstract class BasePreference( - val key: String? = null, - val titleKey: String? = "${key}_title", - val summaryKey: String? = "${key}_summary", - icon: String? = null, - layout: String? = null, - val tag: String -) { - - var icon: String? = icon - internal set - - var layout: String? = layout - internal set - - /** - * Serialize preference element to XML. - * Overriding methods should invoke super and operate on its return value. - * - * @param resourceCallback A callback for additional resources. - * @param ownerDocument Target document to create elements from. - * - * @return The serialized element. - */ - open fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit): Element = - ownerDocument.createElement(tag).apply { - key?.let { setAttribute("android:key", it) } - titleKey?.let { setAttribute("android:title", "@string/${titleKey}") } - summaryKey?.let { addSummary(it) } - icon?.let { - setAttribute("android:icon", it) - setAttribute("app:iconSpaceReserved", "true") - } - layout?.let { setAttribute("android:layout", layout) } - } - - override fun hashCode(): Int { - var result = key?.hashCode() ?: 0 - result = 31 * result + titleKey.hashCode() - result = 31 * result + tag.hashCode() - return result - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false - - other as BasePreference - - if (key != other.key) return false - if (titleKey != other.titleKey) return false - if (tag != other.tag) return false - - return true - } - - companion object { - fun Element.addSummary(summaryKey: String, summaryType: SummaryType = SummaryType.DEFAULT) = - setAttribute("android:${summaryType.type}", "@string/$summaryKey") - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen.kt deleted file mode 100644 index 8590e99..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen.kt +++ /dev/null @@ -1,100 +0,0 @@ -package app.revanced.patches.shared.misc.settings.preference - -import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference.Sorting -import java.io.Closeable - -abstract class BasePreferenceScreen( - private val root: MutableSet = mutableSetOf(), -) : Closeable { - - override fun close() { - if (root.isEmpty()) return - - root.forEach { preference -> - commit(preference.transform()) - } - } - - /** - * Finalize and insert root preference into resource patch - */ - abstract fun commit(screen: PreferenceScreenPreference) - - open inner class Screen( - key: String? = null, - titleKey: String = "${key}_title", - private val summaryKey: String? = "${key}_summary", - icon: String? = null, - layout: String? = null, - preferences: MutableSet = mutableSetOf(), - val categories: MutableSet = mutableSetOf(), - private val sorting: Sorting = Sorting.BY_TITLE, - ) : BasePreferenceCollection(key, titleKey, icon, layout, preferences) { - - override fun transform(): PreferenceScreenPreference { - return PreferenceScreenPreference( - key, - titleKey, - summaryKey, - icon, - layout, - sorting, - // Screens and preferences are sorted at runtime by extension code, - // so title sorting uses the localized language in use. - preferences = preferences + categories.map { it.transform() }, - ) - } - - private fun ensureScreenInserted() { - // Add to screens if not yet done - if (!root.contains(this)) { - root.add(this) - } - } - - fun addPreferences(vararg preferences: BasePreference) { - ensureScreenInserted() - this.preferences.addAll(preferences) - } - - open inner class Category( - key: String? = null, - titleKey: String = "${key}_title", - icon: String? = null, - layout: String? = null, - preferences: MutableSet = mutableSetOf(), - ) : BasePreferenceCollection(key, titleKey, icon, layout, preferences) { - override fun transform(): PreferenceCategory { - return PreferenceCategory( - key, - titleKey, - icon, - layout, - sorting, - preferences = preferences, - ) - } - - fun addPreferences(vararg preferences: BasePreference) { - ensureScreenInserted() - - // Add to the categories if not done yet. - if (!categories.contains(this)) { - categories.add(this) - } - - this.preferences.addAll(preferences) - } - } - } - - abstract class BasePreferenceCollection( - val key: String? = null, - val titleKey: String = "${key}_title", - val icon: String? = null, - val layout: String? = null, - val preferences: MutableSet = mutableSetOf(), - ) { - abstract fun transform(): BasePreference - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/InputType.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/InputType.kt deleted file mode 100644 index 88857cd..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/InputType.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.shared.misc.settings.preference - -enum class InputType(val type: String) { - TEXT("text"), - TEXT_CAP_CHARACTERS("textCapCharacters"), - TEXT_MULTI_LINE("textMultiLine"), - NUMBER("number"), - NUMBER_DECIMAL("numberDecimal"), -} \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/IntentPreference.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/IntentPreference.kt deleted file mode 100644 index 2aef02d..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/IntentPreference.kt +++ /dev/null @@ -1,57 +0,0 @@ -package app.revanced.patches.shared.misc.settings.preference - -import app.revanced.util.resource.BaseResource -import org.w3c.dom.Document - -/** - * A preference that opens an intent. - * - * @param key Optional preference key. - * @param titleKey The preference title key. - * @param summaryKey The preference summary key. - * @param icon The preference icon resource name. - * @param layout Layout declaration. - * @param tag The preference tag. - * @param intent The intent to open. - */ -class IntentPreference( - key: String? = null, - titleKey: String = "${key}_title", - summaryKey: String? = "${key}_summary", - icon: String? = null, - layout: String? = null, - tag: String = "Preference", - val intent: Intent, -) : BasePreference(key, titleKey, summaryKey, icon, layout, tag) { - - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = - super.serialize(ownerDocument, resourceCallback).apply { - appendChild(ownerDocument.createElement("intent").also { intentNode -> - intentNode.setAttribute("android:data", intent.data) - intentNode.setAttribute("android:targetClass", intent.targetClass) - intentNode.setAttribute("android:targetPackage", intent.targetPackageSupplier()) - }) - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false - if (!super.equals(other)) return false - - other as IntentPreference - - return intent == other.intent - } - - override fun hashCode(): Int { - var result = super.hashCode() - result = 31 * result + intent.hashCode() - return result - } - - data class Intent( - internal val data: String, - internal val targetClass: String, - internal val targetPackageSupplier: () -> String, - ) -} diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/ListPreference.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/ListPreference.kt deleted file mode 100644 index e6d9b44..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/ListPreference.kt +++ /dev/null @@ -1,76 +0,0 @@ -package app.revanced.patches.shared.misc.settings.preference - -import app.revanced.util.resource.ArrayResource -import app.revanced.util.resource.BaseResource -import org.w3c.dom.Document - -/** - * List preference. - * - * @param key The preference key. If null, other parameters must be specified. - * @param titleKey The preference title key. - * @param summaryKey The preference summary key. - * @param icon The preference icon resource name. - * @param layout Layout declaration. - * @param tag The preference tag. - * @param entriesKey The entries array key. - * @param entryValuesKey The entry values array key. - */ -@Suppress("MemberVisibilityCanBePrivate") -class ListPreference( - key: String? = null, - titleKey: String = "${key}_title", - summaryKey: String? = "${key}_summary", - icon: String? = null, - layout: String? = null, - tag: String = "ListPreference", - val entriesKey: String? = "${key}_entries", - val entryValuesKey: String? = "${key}_entry_values" -) : BasePreference(key, titleKey, summaryKey, icon, layout, tag) { - var entries: ArrayResource? = null - private set - var entryValues: ArrayResource? = null - private set - - /** - * List preference. - * - * @param key The preference key. If null, other parameters must be specified. - * @param titleKey The preference title key. - * @param summaryKey The preference summary key. - * @param tag The preference tag. - * @param entries The entries array. - * @param entryValues The entry values array. - */ - constructor( - key: String? = null, - titleKey: String = "${key}_title", - summaryKey: String? = "${key}_summary", - tag: String = "ListPreference", - entries: ArrayResource, - entryValues: ArrayResource - ) : this(key, titleKey, summaryKey, tag, entries.name, entryValues.name) { - this.entries = entries - this.entryValues = entryValues - } - - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = - super.serialize(ownerDocument, resourceCallback).apply { - val entriesArrayName = entries?.also { resourceCallback.invoke(it) }?.name ?: entriesKey - val entryValuesArrayName = entryValues?.also { resourceCallback.invoke(it) }?.name ?: entryValuesKey - - entriesArrayName?.let { - setAttribute( - "android:entries", - "@array/$it" - ) - } - - entryValuesArrayName?.let { - setAttribute( - "android:entryValues", - "@array/$it" - ) - } - } -} \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/NonInteractivePreference.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/NonInteractivePreference.kt deleted file mode 100644 index b5ce554..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/NonInteractivePreference.kt +++ /dev/null @@ -1,32 +0,0 @@ -package app.revanced.patches.shared.misc.settings.preference - -import app.revanced.util.resource.BaseResource -import org.w3c.dom.Document - -/** - * A non-interactive preference. - * - * Typically used to present static text, but also used for custom extension code that responds to taps. - * - * @param key The preference key. - * @param summaryKey The preference summary key. - * @param icon The preference icon resource name. - * @param layout Layout declaration. - * @param tag The tag or full class name of the preference. - * @param selectable If the preference is selectable and responds to tap events. - */ -@Suppress("MemberVisibilityCanBePrivate") -class NonInteractivePreference( - key: String, - titleKey: String = "${key}_title", - summaryKey: String? = "${key}_summary", - icon: String? = null, - layout: String? = null, - tag: String = "Preference", - val selectable: Boolean = false, -) : BasePreference(key, titleKey, summaryKey, icon, layout, tag) { - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = - super.serialize(ownerDocument, resourceCallback).apply { - setAttribute("android:selectable", selectable.toString()) - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceCategory.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceCategory.kt deleted file mode 100644 index ef51eca..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceCategory.kt +++ /dev/null @@ -1,34 +0,0 @@ -package app.revanced.patches.shared.misc.settings.preference - -import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference.Sorting -import app.revanced.util.resource.BaseResource -import org.w3c.dom.Document - -/** - * A preference category. - * - * @param key The key of the preference. If null, other parameters must be specified. - * @param titleKey The key of the preference title. - * @param icon The preference icon resource name. - * @param layout Layout declaration. - * @param tag The tag or full class name of the preference. - * @param preferences The preferences in this category. - */ -@Suppress("MemberVisibilityCanBePrivate") -open class PreferenceCategory( - key: String? = null, - titleKey: String? = "${key}_title", - icon: String? = null, - layout: String? = null, - sorting: Sorting = Sorting.BY_TITLE, - tag: String = "PreferenceCategory", - val preferences: Set -) : BasePreference(sorting.appendSortType(key), titleKey, null, icon, layout, tag) { - - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = - super.serialize(ownerDocument, resourceCallback).apply { - preferences.forEach { - appendChild(it.serialize(ownerDocument, resourceCallback)) - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference.kt deleted file mode 100644 index a37e929..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceScreenPreference.kt +++ /dev/null @@ -1,72 +0,0 @@ -package app.revanced.patches.shared.misc.settings.preference - -import app.revanced.util.resource.BaseResource -import org.w3c.dom.Document - -/** - * A preference screen. - * - * @param key The key of the preference. If null, other parameters must be specified. - * @param titleKey The key of the preference title. - * @param summaryKey The key of the preference summary. - * @param icon The preference icon resource name. - * @param layout Layout declaration. - * @param sorting Sorting to use. If the sorting is not [Sorting.UNSORTED], - * then the key parameter will be modified to include the sort type. - * @param tag The tag or full class name of the preference. - * @param preferences The preferences in this screen. - */ -@Suppress("MemberVisibilityCanBePrivate") -open class PreferenceScreenPreference( - key: String? = null, - titleKey: String = "${key}_title", - summaryKey: String? = "${key}_summary", - icon: String? = null, - layout: String? = null, - sorting: Sorting = Sorting.BY_TITLE, - tag: String = "PreferenceScreen", - val preferences: Set, - // Alternatively, instead of repurposing the key for sorting, - // an extra bundle parameter can be added to the preferences XML declaration. - // This would require bundling and referencing an additional XML file - // or adding new attributes to the attrs.xml file. - // Since the key value is not currently used by the extensions, - // for now it's much simpler to modify the key to include the sort parameter. -) : BasePreference(sorting.appendSortType(key), titleKey, summaryKey, icon, layout, tag) { - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = - super.serialize(ownerDocument, resourceCallback).apply { - preferences.forEach { - appendChild(it.serialize(ownerDocument, resourceCallback)) - } - } - - /** - * How a PreferenceScreen should be sorted. - */ - enum class Sorting(val keySuffix: String) { - /** - * Sort by the localized preference title. - */ - BY_TITLE("_sort_by_title"), - - /** - * Sort by the preference keys. - */ - BY_KEY("_sort_by_key"), - - /** - * Unspecified sorting. - */ - UNSORTED("_sort_by_unsorted"); - - /** - * @return The key with this sort type appended to to the end, - * or if key is null then null is returned. - */ - fun appendSortType(key: String?): String? { - if (key == null) return null - if (this == UNSORTED) return key - return key + keySuffix - } - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/SummaryType.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/SummaryType.kt deleted file mode 100644 index ccf547b..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/SummaryType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package app.revanced.patches.shared.misc.settings.preference - -enum class SummaryType(val type: String) { - DEFAULT("summary"), ON("summaryOn"), OFF("summaryOff") -} \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/SwitchPreference.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/SwitchPreference.kt deleted file mode 100644 index df9accd..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/SwitchPreference.kt +++ /dev/null @@ -1,32 +0,0 @@ -package app.revanced.patches.shared.misc.settings.preference - -import app.revanced.util.resource.BaseResource -import org.w3c.dom.Document - -/** - * A switch preference. - * - * @param key The preference key. If null, other parameters must be specified. - * @param titleKey The preference title key. - * @param icon The preference icon resource name. - * @param layout Layout declaration. - * @param tag The preference tag. - * @param summaryOnKey The preference summary-on key. - * @param summaryOffKey The preference summary-off key. - */ -@Suppress("MemberVisibilityCanBePrivate") -class SwitchPreference( - key: String? = null, - titleKey: String = "${key}_title", - tag: String = "SwitchPreference", - icon: String? = null, - layout: String? = null, - val summaryOnKey: String = "${key}_summary_on", - val summaryOffKey: String = "${key}_summary_off" -) : BasePreference(key, titleKey, null, icon, layout, tag) { - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = - super.serialize(ownerDocument, resourceCallback).apply { - addSummary(summaryOnKey, SummaryType.ON) - addSummary(summaryOffKey, SummaryType.OFF) - } -} diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/TextPreference.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/TextPreference.kt deleted file mode 100644 index 397d4bd..0000000 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/TextPreference.kt +++ /dev/null @@ -1,32 +0,0 @@ -package app.revanced.patches.shared.misc.settings.preference - -import app.revanced.util.resource.BaseResource -import org.w3c.dom.Document - -/** - * A text preference. - * - * @param key The preference key. If null, other parameters must be specified. - * @param titleKey The preference title key. - * @param summaryKey The preference summary key. - * @param icon The preference icon resource name. - * @param layout Layout declaration. - * @param tag The preference tag. - * @param inputType The preference input type. - */ -@Suppress("MemberVisibilityCanBePrivate") -class TextPreference( - key: String? = null, - titleKey: String = "${key}_title", - summaryKey: String? = "${key}_summary", - icon: String? = null, - layout: String? = null, - tag: String = "app.revanced.extension.shared.settings.preference.ResettableEditTextPreference", - val inputType: InputType = InputType.TEXT -) : BasePreference(key, titleKey, summaryKey, icon, layout, tag) { - - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = - super.serialize(ownerDocument, resourceCallback).apply { - setAttribute("android:inputType", inputType.type) - } -}