|
16 | 16 | import com.wmods.wppenhacer.xposed.core.WppCore; |
17 | 17 | import com.wmods.wppenhacer.xposed.core.devkit.Unobfuscator; |
18 | 18 | import com.wmods.wppenhacer.xposed.utils.AnimationUtil; |
| 19 | +import com.wmods.wppenhacer.xposed.utils.DebugUtils; |
19 | 20 | import com.wmods.wppenhacer.xposed.utils.ReflectionUtils; |
20 | 21 | import com.wmods.wppenhacer.xposed.utils.ResId; |
21 | 22 | import com.wmods.wppenhacer.xposed.utils.Utils; |
22 | 23 |
|
23 | 24 | import org.json.JSONObject; |
24 | 25 |
|
| 26 | +import java.lang.reflect.Method; |
25 | 27 | import java.util.ArrayList; |
26 | 28 | import java.util.HashMap; |
27 | 29 | import java.util.Objects; |
@@ -182,41 +184,64 @@ private void callInfo() throws Exception { |
182 | 184 | if (!prefs.getBoolean("call_info", false)) |
183 | 185 | return; |
184 | 186 |
|
| 187 | + var clsCallEventCallback = classLoader.loadClass("com.whatsapp.calling.service.VoiceServiceEventCallback"); |
| 188 | + for (Method method : clsCallEventCallback.getDeclaredMethods()) { |
| 189 | + XposedBridge.hookMethod(method, DebugUtils.getDebugMethodHook(false, false, true, true)); |
| 190 | + } |
| 191 | + |
| 192 | + |
185 | 193 | Class<?> clsWamCall = classLoader.loadClass("com.whatsapp.fieldstats.events.WamCall"); |
186 | | - XposedBridge.hookAllMethods(clsWamCall, "serialize", |
| 194 | + |
| 195 | + XposedBridge.hookAllMethods(clsCallEventCallback, "fieldstatsReady", |
187 | 196 | new XC_MethodHook() { |
188 | 197 | @Override |
189 | | - protected void afterHookedMethod(MethodHookParam param) throws Throwable { |
190 | | - var wamCall = param.thisObject; |
191 | | - var ip = (String)XposedHelpers.getObjectField(wamCall, "callPeerIpStr"); |
192 | | - var platform = (String)XposedHelpers.getObjectField(wamCall, "callPeerPlatform"); |
193 | | - CompletableFuture.runAsync(() -> { |
194 | | - try { |
195 | | - showCallInformation(ip, platform); |
196 | | - } catch (Exception e) { |
197 | | - logDebug(e); |
198 | | - } |
199 | | - }); |
| 198 | + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { |
| 199 | + if (clsWamCall.isInstance(param.args[0])) { |
| 200 | + |
| 201 | + Object callinfo = XposedHelpers.callMethod(param.thisObject, "getCallInfo"); |
| 202 | + if (callinfo == null) |
| 203 | + return; |
| 204 | + var userJid = XposedHelpers.callMethod(callinfo, "getPeerJid"); |
| 205 | + CompletableFuture.runAsync(() -> { |
| 206 | + try { |
| 207 | + showCallInformation(param.args[0], userJid); |
| 208 | + } catch (Exception e) { |
| 209 | + logDebug(e); |
| 210 | + } |
| 211 | + }); |
| 212 | + } |
200 | 213 | } |
201 | 214 | }); |
202 | 215 | } |
203 | 216 |
|
204 | | - private void showCallInformation(String ip, String platform) throws Exception { |
205 | | - var db = new StringBuilder(); |
| 217 | + private void showCallInformation(Object wamCall, Object userJid) throws Exception { |
| 218 | + if (WppCore.isGroup(WppCore.getRawString(userJid))) |
| 219 | + return; |
| 220 | + var sb = new StringBuilder(); |
| 221 | + |
| 222 | + var contact = WppCore.getContactName(userJid); |
| 223 | + if (!TextUtils.isEmpty(contact)) |
| 224 | + sb.append("Contact: ").append(contact).append("\n"); |
| 225 | + sb.append("Number: ").append("+").append(WppCore.stripJID(WppCore.getRawString(userJid))).append("\n"); |
| 226 | + |
| 227 | + var ip = (String) XposedHelpers.getObjectField(wamCall, "callPeerIpStr"); |
206 | 228 | if (ip != null) { |
207 | | - var client = new OkHttpClient(); |
208 | | - var url = "http://ip-api.com/json/" + ip; |
209 | | - var request = new okhttp3.Request.Builder().url(url).build(); |
210 | | - var content = client.newCall(request).execute().body().string(); |
211 | | - var json = new JSONObject(content); |
212 | | - var country = json.getString("country"); |
213 | | - var city = json.getString("city"); |
214 | | - db.append("Country: ").append(country).append("\n"); |
215 | | - db.append("City: ").append(city).append("\n"); |
| 229 | + var client = new OkHttpClient(); |
| 230 | + var url = "http://ip-api.com/json/" + ip; |
| 231 | + var request = new okhttp3.Request.Builder().url(url).build(); |
| 232 | + var content = client.newCall(request).execute().body().string(); |
| 233 | + var json = new JSONObject(content); |
| 234 | + var country = json.getString("country"); |
| 235 | + var city = json.getString("city"); |
| 236 | + sb.append("Country: ").append(country).append("\n"); |
| 237 | + sb.append("City: ").append(city).append("\n"); |
| 238 | + sb.append("IP: ").append(ip).append("\n"); |
216 | 239 | } |
217 | | - db.append("Platform: ").append(platform).append("\n"); |
218 | | - db.append("IP: ").append(ip).append("\n"); |
219 | | - Utils.showNotification("Call Information", db.toString()); |
| 240 | + var platform = (String) XposedHelpers.getObjectField(wamCall, "callPeerPlatform"); |
| 241 | + if (platform != null) sb.append("Platform: ").append(platform).append("\n"); |
| 242 | + var wppVersion = (String) XposedHelpers.getObjectField(wamCall, "callPeerAppVersion"); |
| 243 | + if (wppVersion != null) sb.append("WhatsApp Version: ").append(wppVersion).append("\n"); |
| 244 | + Utils.showNotification("Call Information", sb.toString()); |
220 | 245 | } |
221 | 246 |
|
222 | 247 | private void alwaysOnline() throws Exception { |
|
0 commit comments