@@ -364,19 +364,46 @@ private String resolveWaContactName(Context context, Object msgObj, String chatJ
364364 // Check this object for a "name" or "subject" string
365365 String possibleName = getPrivString (fieldVal , "name" );
366366 if (possibleName == null ) possibleName = getPrivString (fieldVal , "subject" );
367- if (possibleName == null ) possibleName = getPrivString (fieldVal , "A0X" ); // Obfuscated name?
367+ if (possibleName == null ) possibleName = getPrivString (fieldVal , "subjectRaw" );
368+ if (possibleName == null ) possibleName = getPrivString (fieldVal , "subject_raw" );
369+ if (possibleName == null ) possibleName = getPrivString (fieldVal , "displayName" );
370+ if (possibleName == null ) possibleName = getPrivString (fieldVal , "nickname" );
371+ if (possibleName == null ) possibleName = getPrivString (fieldVal , "verifiedName" );
372+ if (possibleName == null ) possibleName = getPrivString (fieldVal , "vName" );
373+ if (possibleName == null ) possibleName = getPrivString (fieldVal , "A0X" );
368374 if (possibleName == null ) possibleName = getPrivString (fieldVal , "A0W" );
375+ if (possibleName == null ) possibleName = getPrivString (fieldVal , "A0V" );
376+ if (possibleName == null ) possibleName = getPrivString (fieldVal , "A0Z" );
369377
378+ // Ultimate Fallback: If this object's class looks like a Contact/Chat, scan all string fields
379+ if (possibleName == null && (f .getType ().getName ().contains ("Chat" ) || f .getType ().getName ().contains ("Contact" ))) {
380+ possibleName = findBestNamePattern (fieldVal );
381+ }
382+
370383 // Validation: Names usually don't have @ or are not JIDs
371- if (possibleName != null && !possibleName .contains ("@" ) && possibleName .length () > 0 ) {
372- XposedBridge .log ("WAE: Potentially found name via reflection: " + possibleName );
384+ if (possibleName != null && !possibleName .contains ("@" ) && possibleName .length () > 0 && possibleName . length () < 100 ) {
385+ XposedBridge .log ("WAE: Potentially found name via reflection: " + possibleName + " in field " + f . getName () + " of class " + fieldVal . getClass (). getName () );
373386 return possibleName ;
374387 }
388+
389+ // Second level: Scan fields of THIS fieldVal
390+ if (f .getType ().getName ().startsWith ("com.whatsapp" )) {
391+ String subName = findLongestString (fieldVal );
392+ if (subName != null && !subName .contains ("@" ) && subName .length () > 2 && subName .length () < 50 ) {
393+ // Check if it's likely a name (no dots, no slashes)
394+ if (!subName .contains ("." ) && !subName .contains ("/" ) && !subName .contains (":" )) {
395+ XposedBridge .log ("WAE: Found potential sub-name via findLongestString: " + subName );
396+ return subName ;
397+ }
398+ }
399+ }
375400 }
376401 }
377402 msgClass = msgClass .getSuperclass ();
378403 }
379404
405+ XposedBridge .log ("WAE: resolveWaContactName failed to find name via reflection for " + chatJid );
406+
380407 // Strategy 2: If we failed to find it in msg, fall back to ContactsContract (for individuals)
381408 // But strict cleaning of JID
382409 if (chatJid != null && !chatJid .contains ("@g.us" )) {
@@ -397,6 +424,29 @@ private String getPrivString(Object obj, String name) {
397424 return null ;
398425 }
399426
427+ private String findBestNamePattern (Object obj ) {
428+ if (obj == null ) return null ;
429+ Class <?> cls = obj .getClass ();
430+ while (cls != null && cls != Object .class ) {
431+ for (Field f : cls .getDeclaredFields ()) {
432+ if (f .getType () == String .class ) {
433+ f .setAccessible (true );
434+ try {
435+ String s = (String ) f .get (obj );
436+ if (s != null && s .length () > 0 && s .length () < 50 ) {
437+ // Heuristic: Name usually doesn't have @, :, /, \ and is not a number
438+ if (!s .contains ("@" ) && !s .contains ("/" ) && !s .contains (":" ) && !s .matches ("\\ d+" )) {
439+ return s ;
440+ }
441+ }
442+ } catch (Exception e ) {}
443+ }
444+ }
445+ cls = cls .getSuperclass ();
446+ }
447+ return null ;
448+ }
449+
400450 @ Override
401451 public String getPluginName () {
402452 return "Recover Delete For Me" ;
0 commit comments