Skip to content

Commit 0632388

Browse files
committed
Fix compatibility WA 2.25.7.80
1 parent 07f05e8 commit 0632388

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

app/src/main/java/com/wmods/wppenhacer/xposed/core/devkit/Unobfuscator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,17 +1777,15 @@ public static synchronized Method loadCheckSupportLanguage(ClassLoader classLoad
17771777
}
17781778

17791779
public static synchronized Class loadUnkTranscript(ClassLoader classLoader) throws Exception {
1780-
return UnobfuscatorCache.getInstance().getClass(classLoader, () -> {
17811780
var loadTranscribe = loadTranscribeMethod(classLoader);
17821781
var callbackClass = loadTranscribe.getParameterTypes()[1];
17831782
var onComplete = ReflectionUtils.findMethodUsingFilter(callbackClass, method -> method.getParameterCount() == 4);
17841783
var resultTypeClass = onComplete.getParameterTypes()[0].getName();
17851784
Log.i(TAG, resultTypeClass);
17861785
var classDataList = dexkit.findClass(FindClass.create().matcher(ClassMatcher.create().addUsingString("Unknown").superClass(resultTypeClass)));
17871786
if (classDataList.isEmpty())
1788-
throw new RuntimeException("UnkTranscript class not found");
1787+
return null;
17891788
return classDataList.get(0).getInstance(classLoader);
1790-
});
17911789
}
17921790

17931791
public static synchronized Class loadTranscriptSegment(ClassLoader classLoader) throws Exception {

app/src/main/java/com/wmods/wppenhacer/xposed/features/others/AudioTranscript.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
public class AudioTranscript extends Feature {
2828

29-
3029
public AudioTranscript(@NonNull ClassLoader classLoader, @NonNull XSharedPreferences preferences) {
3130
super(classLoader, preferences);
3231
}
@@ -44,24 +43,28 @@ public void doHook() throws Throwable {
4443
XposedBridge.hookMethod(transcribeMethod, new XC_MethodHook() {
4544
@Override
4645
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
47-
DebugUtils.debugArgs(param.args);
4846
var pttTranscriptionRequest = param.args[0];
4947
var fieldFMessage = ReflectionUtils.getFieldByExtendType(pttTranscriptionRequest.getClass(), FMessageWpp.TYPE);
5048
var fmessageObj = fieldFMessage.get(pttTranscriptionRequest);
5149
var fmessage = new FMessageWpp(fmessageObj);
5250
File file = fmessage.getMediaFile();
5351
var callback = param.args[1];
54-
var mEnglishInstance = ReflectionUtils.getFieldByExtendType(unkTranscriptClass, unkTranscriptClass).get(null);
5552
var onComplete = ReflectionUtils.findMethodUsingFilter(callback.getClass(), method -> method.getParameterCount() == 4);
5653
String transcript = runTranscript(file);
5754
var segments = new ArrayList<>();
58-
var words = transcript.split(" ");
55+
var words = transcript.split("\\s");
5956
var totalLength = 0;
6057
for (var word : words) {
6158
segments.add(XposedHelpers.newInstance(TranscriptionSegmentClass, totalLength, word.length(), 100, -1, -1));
6259
totalLength += word.length() + 1;
6360
}
64-
ReflectionUtils.callMethod(onComplete, callback, mEnglishInstance, fmessageObj, transcript, segments);
61+
// In version 2.25.7.80 the language has been changed to an enum, but I will maintain for compatibility with old versions
62+
if (unkTranscriptClass != null) {
63+
var mEnglishInstance = ReflectionUtils.getFieldByExtendType(unkTranscriptClass, unkTranscriptClass).get(null);
64+
ReflectionUtils.callMethod(onComplete, callback, mEnglishInstance, fmessageObj, transcript, segments);
65+
} else {
66+
ReflectionUtils.callMethod(onComplete, callback, fmessageObj, transcript, segments, 1);
67+
}
6568
param.setResult(null);
6669
}
6770
});

0 commit comments

Comments
 (0)