Skip to content

Commit 49ec3e4

Browse files
committed
Refactor HideSeen and improve Unobfuscator
- Add logging for `HideSeen` status in `HideSeen.java`. - Simplify `loadHideViewInChatMethod` in `Unobfuscator.java` by iterating through a list of strings to find the method. - Remove an unused `TODO` comment in `Unobfuscator.java`. Signed-off-by: Dev4Mod <[email protected]>
1 parent eecd183 commit 49ec3e4

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ public synchronized static Class<?> loadForwardClassMethod(ClassLoader classLoad
323323

324324

325325
// TODO: Classes and Methods for HideView
326-
327326
public synchronized static Method loadHideViewSendReadJob(ClassLoader classLoader) throws Exception {
328327
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
329328
var classData = dexkit.getClassData(XposedHelpers.findClass("com.whatsapp.jobqueue.job.SendReadReceiptJob", classLoader));
@@ -338,11 +337,14 @@ public synchronized static Method loadHideViewSendReadJob(ClassLoader classLoade
338337

339338
public synchronized static Method loadHideViewInChatMethod(ClassLoader classLoader) throws Exception {
340339
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
341-
Method method = findFirstMethodUsingStrings(classLoader, StringMatchType.Contains, "ReadReceipts/acknowledgeMessageIfNeeded");
342-
if (method == null)
343-
method = findFirstMethodUsingStrings(classLoader, StringMatchType.Contains, "ReadReceipts/sendDeliveryReceiptIfNotRetry");
344-
if (method == null) throw new Exception("HideViewInChat method not found");
345-
return method;
340+
var strings = new String[]{
341+
"ReadReceipts/sendDeliveryReadReceipt", "ReadReceipts/acknowledgeMessageIfNeeded", "ReadReceipts/sendDeliveryReceiptIfNotRetry"
342+
};
343+
for (var s : strings) {
344+
var method = findFirstMethodUsingStrings(classLoader, StringMatchType.Contains, s);
345+
if (method != null) return method;
346+
}
347+
throw new Exception("HideViewInChat method not found");
346348
});
347349
}
348350

app/src/main/java/com/wmods/wppenhacer/xposed/features/privacy/HideSeen.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,21 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
9797
Method ReceiptMethod = Unobfuscator.loadReceiptMethod(classLoader);
9898
logDebug(Unobfuscator.getMethodDescriptor(ReceiptMethod));
9999

100-
var method3 = Unobfuscator.loadReceiptOutsideChat(classLoader);
101-
logDebug("Outside Chat", Unobfuscator.getMethodDescriptor(method3));
100+
var outsideMethod = Unobfuscator.loadReceiptOutsideChat(classLoader);
101+
logDebug("Outside Chat", Unobfuscator.getMethodDescriptor(outsideMethod));
102102

103103

104104
XposedBridge.hookMethod(ReceiptMethod, new XC_MethodHook() {
105105
@Override
106106
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
107-
if (ReflectionUtils.isCalledFromMethod(method3) || !ReflectionUtils.isCalledFromMethod(hideViewInChatMethod))
107+
if (ReflectionUtils.isCalledFromMethod(outsideMethod) || !ReflectionUtils.isCalledFromMethod(hideViewInChatMethod))
108108
return;
109109
if (!Objects.equals("read", param.args[4])) return;
110110
var jid = WppCore.getCurrentRawJID();
111111
var number = WppCore.stripJID(jid);
112112
var privacy = CustomPrivacy.getJSON(number);
113113
var customHideRead = privacy.optBoolean("HideSeen", hideread);
114+
log("Hide Seen:" + customHideRead);
114115
if (WppCore.isGroup(jid)) {
115116
if (privacy.optBoolean("HideSeen", hideread_group) || ghostmode) {
116117
param.args[4] = null;

0 commit comments

Comments
 (0)