forked from ReVanced/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…eVanced#2734) Co-authored-by: oSumAtrIX <[email protected]>
- Loading branch information
Showing
5 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/app/revanced/patches/mifitness/misc/locale/ForceEnglishLocalePatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package app.revanced.patches.mifitness.misc.locale | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
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.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patches.mifitness.misc.locale.fingerprints.SyncBluetoothLanguageFingerprint | ||
import app.revanced.patches.mifitness.misc.login.FixLoginPatch | ||
import app.revanced.util.exception | ||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction | ||
|
||
@Patch( | ||
name = "Force English locale", | ||
description = "Forces wearable devices to use the English locale.", | ||
compatiblePackages = [CompatiblePackage("com.xiaomi.wearable")], | ||
dependencies = [FixLoginPatch::class], | ||
) | ||
@Suppress("unused") | ||
object ForceEnglishLocalePatch : BytecodePatch( | ||
setOf(SyncBluetoothLanguageFingerprint), | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
SyncBluetoothLanguageFingerprint.result?.let { | ||
val resolvePhoneLocaleInstruction = it.scanResult.patternScanResult!!.startIndex | ||
|
||
it.mutableMethod.apply { | ||
val registerIndexToUpdate = | ||
getInstruction<OneRegisterInstruction>(resolvePhoneLocaleInstruction).registerA | ||
|
||
replaceInstruction( | ||
resolvePhoneLocaleInstruction, | ||
"const-string v$registerIndexToUpdate, \"en_gb\"", | ||
) | ||
} | ||
} ?: throw SyncBluetoothLanguageFingerprint.exception | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...p/revanced/patches/mifitness/misc/locale/fingerprints/SyncBluetoothLanguageFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package app.revanced.patches.mifitness.misc.locale.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import com.android.tools.smali.dexlib2.Opcode | ||
|
||
internal object SyncBluetoothLanguageFingerprint : MethodFingerprint( | ||
customFingerprint = { methodDef, _ -> | ||
methodDef.definingClass == "Lcom/xiaomi/fitness/devicesettings/DeviceSettingsSyncer;" && | ||
methodDef.name == "syncBluetoothLanguage" | ||
}, | ||
opcodes = listOf(Opcode.MOVE_RESULT_OBJECT), | ||
) |
35 changes: 35 additions & 0 deletions
35
src/main/kotlin/app/revanced/patches/mifitness/misc/login/FixLoginPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package app.revanced.patches.mifitness.misc.login | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patches.mifitness.misc.login.fingerprints.XiaomiAccountManagerConstructorFingerprint | ||
import app.revanced.util.exception | ||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction | ||
|
||
@Patch( | ||
name = "Fix login", | ||
description = "Fixes login for uncertified Mi Fitness app", | ||
compatiblePackages = [CompatiblePackage("com.xiaomi.wearable")], | ||
) | ||
@Suppress("unused") | ||
object FixLoginPatch : BytecodePatch( | ||
setOf(XiaomiAccountManagerConstructorFingerprint), | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
XiaomiAccountManagerConstructorFingerprint.result?.let { | ||
it.mutableMethod.apply { | ||
val isCertifiedIndex = it.scanResult.patternScanResult!!.startIndex | ||
val isCertifiedRegister = getInstruction<OneRegisterInstruction>(isCertifiedIndex).registerA | ||
|
||
addInstruction( | ||
isCertifiedIndex, | ||
"const/4 p$isCertifiedRegister, 0x0", | ||
) | ||
} | ||
} ?: throw XiaomiAccountManagerConstructorFingerprint.exception | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...d/patches/mifitness/misc/login/fingerprints/XiaomiAccountManagerConstructorFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package app.revanced.patches.mifitness.misc.login.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import com.android.tools.smali.dexlib2.AccessFlags | ||
import com.android.tools.smali.dexlib2.Opcode | ||
|
||
internal object XiaomiAccountManagerConstructorFingerprint : MethodFingerprint( | ||
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR, | ||
customFingerprint = { methodDef, _ -> | ||
methodDef.definingClass == "Lcom/xiaomi/passport/accountmanager/XiaomiAccountManager;" | ||
}, | ||
opcodes = listOf(Opcode.IF_NEZ), | ||
) |