Skip to content

Commit bbef782

Browse files
authored
Merge pull request #166 from frknkrc44/feat-22-xx-support
feat: Add initial 22.xx support
2 parents 3f0a350 + 3f73099 commit bbef782

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.util.ArrayList;
3939
import java.util.Arrays;
4040
import java.util.Calendar;
41+
import java.util.Collections;
4142
import java.util.Date;
4243
import java.util.HashMap;
4344
import java.util.List;
@@ -835,6 +836,19 @@ public synchronized static Method loadSendPresenceMethod(ClassLoader loader) thr
835836
return UnobfuscatorCache.getInstance().getMethod(loader, () -> {
836837
var method = findFirstMethodUsingStrings(loader, StringMatchType.Contains, "app/send-presence-subscription jid=");
837838
if (method == null) throw new Exception("SendPresence method not found");
839+
840+
// for 22.xx, method returns wrong one
841+
var methodData = dexkit.getMethodData(method);
842+
var groupJidClass = XposedHelpers.findClass("com.whatsapp.jid.GroupJid", loader);
843+
var classCheckMethod = dexkit.findMethod(FindMethod.create()
844+
.searchInClass(Collections.singletonList(methodData.getDeclaredClass()))
845+
.matcher(MethodMatcher.create().returnType(groupJidClass)))
846+
.singleOrNull();
847+
if (classCheckMethod == null) {
848+
var newMethod = methodData.getCallers().firstOrNull();
849+
if (newMethod == null) throw new Exception("SendPresence method not found 2");
850+
return newMethod.getMethodInstance(loader);
851+
}
838852
return method;
839853
});
840854
}
@@ -1211,6 +1225,11 @@ public synchronized static Method loadMaterialAlertDialog(ClassLoader loader) th
12111225
if (invoke.isMethod() && Modifier.isStatic(invoke.getModifiers()) && invoke.getParamCount() == 1 && invoke.getParamTypes().get(0).getName().equals(Context.class.getName())) {
12121226
return invoke.getMethodInstance(loader);
12131227
}
1228+
1229+
// for 22.xx, MaterialAlertDialog method is not static
1230+
if (invoke.isMethod() && invoke.getParamCount() == 1 && invoke.getParamTypes().get(0).getName().equals(Context.class.getName())) {
1231+
return invoke.getMethodInstance(loader);
1232+
}
12141233
}
12151234
throw new RuntimeException("MaterialAlertDialog not found");
12161235
});
@@ -1477,8 +1496,13 @@ public synchronized static Method loadPlaybackSpeed(ClassLoader classLoader) thr
14771496
public synchronized static Constructor loadListUpdateItemsConstructor(ClassLoader classLoader) throws Exception {
14781497
return UnobfuscatorCache.getInstance().getConstructor(classLoader, () -> {
14791498
var method = dexkit.findMethod(new FindMethod().matcher(new MethodMatcher().paramCount(1).returnType(void.class).addParamType(Object.class).addUsingNumber(8686)));
1480-
if (method.isEmpty())
1481-
throw new RuntimeException("ListUpdateItems method not found");
1499+
if (method.isEmpty()) {
1500+
// for 22.xx, use alternative method
1501+
method = dexkit.findMethod(new FindMethod().matcher(new MethodMatcher().paramCount(1).returnType(void.class).addUsingString("deleted", StringMatchType.Equals).addUsingString("membership", StringMatchType.Equals)));
1502+
1503+
if (method.isEmpty())
1504+
throw new RuntimeException("ListUpdateItems method not found");
1505+
}
14821506
return method.get(0).getClassInstance(classLoader).getConstructors()[0];
14831507
});
14841508
}

app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/ShowOnline.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
149149
Class<?> JidClass = classLoader.loadClass("com.whatsapp.jid.Jid");
150150
var method = ReflectionUtils.findMethodUsingFilter(sendPresenceMethod.getDeclaringClass(), method1 -> method1.getParameterCount() == 2 && JidClass.isAssignableFrom(method1.getParameterTypes()[0]) && method1.getParameterTypes()[1] == sendPresenceMethod.getDeclaringClass());
151151
var instance = ReflectionUtils.callMethod(method, null, jidObject, mInstancePresence); //XposedHelpers.newInstance(clazz, new Object[]{null, null});
152-
sendPresenceMethod.invoke(null, jidObject, instance, mInstancePresence);
152+
// for 22.xx, the parameter count is 4
153+
if (sendPresenceMethod.getParameterCount() == 4) {
154+
sendPresenceMethod.invoke(null, jidObject, null, instance, mInstancePresence);
155+
} else {
156+
sendPresenceMethod.invoke(null, jidObject, instance, mInstancePresence);
157+
}
153158
var status = (String) ReflectionUtils.callMethod(getStatusUser, mStatusUser, object, false);
154159
var currentPosition = (int) ReflectionUtils.callMethod(getAdapterPositionMethod, viewHolder);
155160
if (currentPosition != position) return;

app/src/main/res/values/arrays.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
<item>2.24.19.xx</item>
122122
<item>2.24.20.xx</item>
123123
<item>2.24.21.xx</item>
124+
<item>2.24.22.xx</item>
124125
</string-array>
125126
<string-array name="supported_versions_business">
126127
<item>2.24.16.xx</item>
@@ -129,6 +130,7 @@
129130
<item>2.24.19.xx</item>
130131
<item>2.24.20.xx</item>
131132
<item>2.24.21.xx</item>
133+
<item>2.24.22.xx</item>
132134
</string-array>
133135
<string-array name="image_picker">
134136
<item>image/*</item>

0 commit comments

Comments
 (0)