Skip to content

Commit 205105c

Browse files
committed
add hook property
Signed-off-by: Dev4Mod <[email protected]>
1 parent 6f0def7 commit 205105c

File tree

1 file changed

+75
-61
lines changed
  • app/src/main/java/com/wmods/wppenhacer/xposed/features/general

1 file changed

+75
-61
lines changed

app/src/main/java/com/wmods/wppenhacer/xposed/features/general/Others.java

Lines changed: 75 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import java.util.ArrayList;
2727
import java.util.HashMap;
28+
import java.util.HashSet;
2829
import java.util.Objects;
2930
import java.util.Properties;
3031
import java.util.concurrent.CompletableFuture;
@@ -38,6 +39,8 @@
3839

3940
public class Others extends Feature {
4041

42+
public static HashSet<HookProperty> hooksProperties = new HashSet<>();
43+
4144
public static HashMap<Integer, Boolean> propsBoolean = new HashMap<>();
4245
public static HashMap<Integer, Integer> propsInteger = new HashMap<>();
4346
private Properties properties;
@@ -104,7 +107,10 @@ public void doHook() throws Exception {
104107
propsBoolean.put(11066, animationEmojis); // emojis map 3
105108

106109
propsBoolean.put(7589, true); // Media select quality
107-
propsBoolean.put(6972, false); // Media select quality
110+
propsBoolean.put(6972, true); // Media select quality
111+
propsBoolean.put(5868, true); // Media select quality
112+
propsBoolean.put(8543, true); // Media select quality
113+
108114
propsBoolean.put(5625, true); // Enable option to autodelete channels media
109115

110116
propsBoolean.put(8643, true); // Enable TextStatusComposerActivityV2
@@ -186,6 +192,37 @@ public void doHook() throws Exception {
186192

187193
}
188194

195+
private void showCallInformation(Object wamCall, Object userJid) throws Exception {
196+
if (WppCore.isGroup(WppCore.getRawString(userJid)))
197+
return;
198+
var sb = new StringBuilder();
199+
var contact = WppCore.getContactName(userJid);
200+
var number = WppCore.stripJID(WppCore.getRawString(userJid));
201+
if (!TextUtils.isEmpty(contact))
202+
sb.append(String.format(Utils.getApplication().getString(ResId.string.contact_s), contact)).append("\n");
203+
sb.append(String.format(Utils.getApplication().getString(ResId.string.phone_number_s), number)).append("\n");
204+
var ip = (String) XposedHelpers.getObjectField(wamCall, "callPeerIpStr");
205+
if (ip != null) {
206+
var client = new OkHttpClient();
207+
var url = "http://ip-api.com/json/" + ip;
208+
var request = new okhttp3.Request.Builder().url(url).build();
209+
var content = client.newCall(request).execute().body().string();
210+
var json = new JSONObject(content);
211+
var country = json.getString("country");
212+
var city = json.getString("city");
213+
sb.append(String.format(Utils.getApplication().getString(ResId.string.country_s), country)).append("\n")
214+
.append(String.format(Utils.getApplication().getString(ResId.string.city_s), city)).append("\n")
215+
.append(String.format(Utils.getApplication().getString(ResId.string.ip_s), ip)).append("\n");
216+
}
217+
var platform = (String) XposedHelpers.getObjectField(wamCall, "callPeerPlatform");
218+
if (platform != null)
219+
sb.append(String.format(Utils.getApplication().getString(ResId.string.platform_s), platform)).append("\n");
220+
var wppVersion = (String) XposedHelpers.getObjectField(wamCall, "callPeerAppVersion");
221+
if (wppVersion != null)
222+
sb.append(String.format(Utils.getApplication().getString(ResId.string.wpp_version_s), wppVersion)).append("\n");
223+
Utils.showNotification(Utils.getApplication().getString(ResId.string.call_information), sb.toString());
224+
}
225+
189226
private void callInfo() throws Exception {
190227
if (!prefs.getBoolean("call_info", false))
191228
return;
@@ -215,32 +252,41 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
215252
});
216253
}
217254

218-
private void showCallInformation(Object wamCall, Object userJid) throws Exception {
219-
if (WppCore.isGroup(WppCore.getRawString(userJid)))
220-
return;
221-
var sb = new StringBuilder();
222-
var contact = WppCore.getContactName(userJid);
223-
var number = WppCore.stripJID(WppCore.getRawString(userJid));
224-
if (!TextUtils.isEmpty(contact)) sb.append(String.format(Utils.getApplication().getString(ResId.string.contact_s), contact)).append("\n");
225-
sb.append(String.format(Utils.getApplication().getString(ResId.string.phone_number_s), number)).append("\n");
226-
var ip = (String) XposedHelpers.getObjectField(wamCall, "callPeerIpStr");
227-
if (ip != null) {
228-
var client = new OkHttpClient();
229-
var url = "http://ip-api.com/json/" + ip;
230-
var request = new okhttp3.Request.Builder().url(url).build();
231-
var content = client.newCall(request).execute().body().string();
232-
var json = new JSONObject(content);
233-
var country = json.getString("country");
234-
var city = json.getString("city");
235-
sb.append(String.format(Utils.getApplication().getString(ResId.string.country_s), country)).append("\n")
236-
.append(String.format(Utils.getApplication().getString(ResId.string.city_s), city)).append("\n")
237-
.append(String.format(Utils.getApplication().getString(ResId.string.ip_s), ip)).append("\n");
238-
}
239-
var platform = (String) XposedHelpers.getObjectField(wamCall, "callPeerPlatform");
240-
if (platform != null) sb.append(String.format(Utils.getApplication().getString(ResId.string.platform_s), platform)).append("\n");
241-
var wppVersion = (String) XposedHelpers.getObjectField(wamCall, "callPeerAppVersion");
242-
if (wppVersion != null) sb.append(String.format(Utils.getApplication().getString(ResId.string.wpp_version_s), wppVersion)).append("\n");
243-
Utils.showNotification(Utils.getApplication().getString(ResId.string.call_information), sb.toString());
255+
private void hookProps() throws Exception {
256+
var methodPropsBoolean = Unobfuscator.loadPropsBooleanMethod(classLoader);
257+
logDebug(Unobfuscator.getMethodDescriptor(methodPropsBoolean));
258+
var dataUsageActivityClass = XposedHelpers.findClass("com.whatsapp.settings.SettingsDataUsageActivity", classLoader);
259+
XposedBridge.hookMethod(methodPropsBoolean, new XC_MethodHook() {
260+
@Override
261+
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
262+
int i = (int) param.args[param.args.length - 1];
263+
var propValue = (boolean) param.getResult();
264+
var value = propsBoolean.getOrDefault(i, propValue);
265+
if (i == 4023) {
266+
if (ReflectionUtils.isCalledFromClass(dataUsageActivityClass))
267+
return;
268+
}
269+
for (var hookProp : hooksProperties) {
270+
value = (boolean) hookProp.hook(boolean.class, i, value);
271+
}
272+
param.setResult(value);
273+
}
274+
});
275+
276+
var methodPropsInteger = Unobfuscator.loadPropsIntegerMethod(classLoader);
277+
278+
XposedBridge.hookMethod(methodPropsInteger, new XC_MethodHook() {
279+
@Override
280+
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
281+
int i = (int) param.args[param.args.length - 1];
282+
var propValue = (int) param.getResult();
283+
var value = propsInteger.getOrDefault(i, propValue);
284+
for (var hookProp : hooksProperties) {
285+
value = (int) hookProp.hook(int.class, i, value);
286+
}
287+
param.setResult(value);
288+
}
289+
});
244290
}
245291

246292
private void alwaysOnline() throws Exception {
@@ -461,40 +507,8 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
461507
}
462508

463509

464-
private void hookProps() throws Exception {
465-
var methodPropsBoolean = Unobfuscator.loadPropsBooleanMethod(classLoader);
466-
logDebug(Unobfuscator.getMethodDescriptor(methodPropsBoolean));
467-
var dataUsageActivityClass = XposedHelpers.findClass("com.whatsapp.settings.SettingsDataUsageActivity", classLoader);
468-
XposedBridge.hookMethod(methodPropsBoolean, new XC_MethodHook() {
469-
@Override
470-
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
471-
int i = (int) param.args[param.args.length - 1];
472-
473-
var propValue = propsBoolean.get(i);
474-
if (propValue != null) {
475-
// Fix Bug in Settings Data Usage
476-
switch (i) {
477-
case 4023:
478-
if (ReflectionUtils.isCalledFromClass(dataUsageActivityClass))
479-
return;
480-
break;
481-
}
482-
param.setResult(propValue);
483-
}
484-
}
485-
});
486-
487-
var methodPropsInteger = Unobfuscator.loadPropsIntegerMethod(classLoader);
488-
489-
XposedBridge.hookMethod(methodPropsInteger, new XC_MethodHook() {
490-
@Override
491-
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
492-
int i = (int) param.args[param.args.length - 1];
493-
var propValue = propsInteger.get(i);
494-
if (propValue == null) return;
495-
param.setResult(propValue);
496-
}
497-
});
510+
public interface HookProperty {
511+
Object hook(Class<?> type, int propertyId, Object propertyValue);
498512
}
499513

500514
private void hookMenuOptions(String filterChats) {

0 commit comments

Comments
 (0)