Skip to content

Commit

Permalink
Merge pull request #166 from frknkrc44/feat-22-xx-support
Browse files Browse the repository at this point in the history
feat: Add initial 22.xx support
  • Loading branch information
Dev4Mod authored Oct 28, 2024
2 parents 3f0a350 + 3f73099 commit bbef782
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -835,6 +836,19 @@ public synchronized static Method loadSendPresenceMethod(ClassLoader loader) thr
return UnobfuscatorCache.getInstance().getMethod(loader, () -> {
var method = findFirstMethodUsingStrings(loader, StringMatchType.Contains, "app/send-presence-subscription jid=");
if (method == null) throw new Exception("SendPresence method not found");

// for 22.xx, method returns wrong one
var methodData = dexkit.getMethodData(method);
var groupJidClass = XposedHelpers.findClass("com.whatsapp.jid.GroupJid", loader);
var classCheckMethod = dexkit.findMethod(FindMethod.create()
.searchInClass(Collections.singletonList(methodData.getDeclaredClass()))
.matcher(MethodMatcher.create().returnType(groupJidClass)))
.singleOrNull();
if (classCheckMethod == null) {
var newMethod = methodData.getCallers().firstOrNull();
if (newMethod == null) throw new Exception("SendPresence method not found 2");
return newMethod.getMethodInstance(loader);
}
return method;
});
}
Expand Down Expand Up @@ -1211,6 +1225,11 @@ public synchronized static Method loadMaterialAlertDialog(ClassLoader loader) th
if (invoke.isMethod() && Modifier.isStatic(invoke.getModifiers()) && invoke.getParamCount() == 1 && invoke.getParamTypes().get(0).getName().equals(Context.class.getName())) {
return invoke.getMethodInstance(loader);
}

// for 22.xx, MaterialAlertDialog method is not static
if (invoke.isMethod() && invoke.getParamCount() == 1 && invoke.getParamTypes().get(0).getName().equals(Context.class.getName())) {
return invoke.getMethodInstance(loader);
}
}
throw new RuntimeException("MaterialAlertDialog not found");
});
Expand Down Expand Up @@ -1477,8 +1496,13 @@ public synchronized static Method loadPlaybackSpeed(ClassLoader classLoader) thr
public synchronized static Constructor loadListUpdateItemsConstructor(ClassLoader classLoader) throws Exception {
return UnobfuscatorCache.getInstance().getConstructor(classLoader, () -> {
var method = dexkit.findMethod(new FindMethod().matcher(new MethodMatcher().paramCount(1).returnType(void.class).addParamType(Object.class).addUsingNumber(8686)));
if (method.isEmpty())
throw new RuntimeException("ListUpdateItems method not found");
if (method.isEmpty()) {
// for 22.xx, use alternative method
method = dexkit.findMethod(new FindMethod().matcher(new MethodMatcher().paramCount(1).returnType(void.class).addUsingString("deleted", StringMatchType.Equals).addUsingString("membership", StringMatchType.Equals)));

if (method.isEmpty())
throw new RuntimeException("ListUpdateItems method not found");
}
return method.get(0).getClassInstance(classLoader).getConstructors()[0];
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Class<?> JidClass = classLoader.loadClass("com.whatsapp.jid.Jid");
var method = ReflectionUtils.findMethodUsingFilter(sendPresenceMethod.getDeclaringClass(), method1 -> method1.getParameterCount() == 2 && JidClass.isAssignableFrom(method1.getParameterTypes()[0]) && method1.getParameterTypes()[1] == sendPresenceMethod.getDeclaringClass());
var instance = ReflectionUtils.callMethod(method, null, jidObject, mInstancePresence); //XposedHelpers.newInstance(clazz, new Object[]{null, null});
sendPresenceMethod.invoke(null, jidObject, instance, mInstancePresence);
// for 22.xx, the parameter count is 4
if (sendPresenceMethod.getParameterCount() == 4) {
sendPresenceMethod.invoke(null, jidObject, null, instance, mInstancePresence);
} else {
sendPresenceMethod.invoke(null, jidObject, instance, mInstancePresence);
}
var status = (String) ReflectionUtils.callMethod(getStatusUser, mStatusUser, object, false);
var currentPosition = (int) ReflectionUtils.callMethod(getAdapterPositionMethod, viewHolder);
if (currentPosition != position) return;
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
<item>2.24.19.xx</item>
<item>2.24.20.xx</item>
<item>2.24.21.xx</item>
<item>2.24.22.xx</item>
</string-array>
<string-array name="supported_versions_business">
<item>2.24.16.xx</item>
Expand All @@ -129,6 +130,7 @@
<item>2.24.19.xx</item>
<item>2.24.20.xx</item>
<item>2.24.21.xx</item>
<item>2.24.22.xx</item>
</string-array>
<string-array name="image_picker">
<item>image/*</item>
Expand Down

0 comments on commit bbef782

Please sign in to comment.